Mapnik supports on-the-fly reprojection of raster layers (like it does for vector layers)
However, for optimal performance it can be best to first (externally) warp an image to the Spatial Reference System (srs) used in the map (e.g. using the
gdalwarpcommand from the gdal-utilities).
As of Mapnik 0.6.0 the RasterSymbolizer supports transparency and composition modes.
See the original ticket for details: #259
See also Compositing for some of the effects.
This Symbolizer is often used with DEM (digital elevation model) data containing missing values (for example NASA SRTM DEM data); to achieve nice rendering, the gdal_fillnodata.py tool might be useful.
As of Mapnik 0.8 the RasterSymbolizer can be assigned a RasterColorizer to color a raw data raster according to a palette. This is useful for visualizing scientific data, dynamically changing the color gradient of a DEM, etc...
Processed as described in http://wiki.openstreetmap.org/wiki/Hillshading_using_the_Alpha_Channel_of_an_Image
|opacity||0.0 - 1.0||1 is fully opaque while zero is fully transparent and .5 would be 50% transparent|
|comp-op (previously called
||grain_merge, grain_merge2, multiply, multiply2, divide, divide2, screen, hard_light||Compositing/Merging effects with image below raster level (?). The formulas for combinding foreground (raster) and background are: grain_merge: bg + fg - 0.5, grain_merge2: bg + 2fg - 1.0, multiply: fg * bg, multiply2: 2 * fg * bg, divide: bg / fg, divide2: 2bg / fg, screen: (1-fg)*(1-bg), hardlight: see http://docs.gimp.org/en/gimp-concepts-layer-modes.html#id2834930|
|scaling||fast, bilinear, bilinear8|
There are three types of raster datasources: gdal, raster or pgraster:
- The GDAL plugin is more convenient as it can read the file extents automatically and supports any GDAL-supported type of file
- The Raster driver only works with Tiled or Stripped GeoTIFF files and requires manually setting the file bounds, but can be faster.
- The PgRaster driver requires manually setting the band number to use as databand.
Default (simply renders a copy of the raster)
<Style name="My Style"> <Rule> <RasterSymbolizer/> </Rule> </Style>
Using the new 0.6.0 release opacity / merging / scaling options:
<Style name="raster"> <Rule> <RasterSymbolizer opacity="0.5" <!-- scaling="fast" --> scaling="bilinear" <!-- scaling="bilinear8" --> <!-- mode="grain_merge" --> <!-- mode="grain_merge2" --> <!-- mode="multiply" --> mode="multiply2" <!-- mode="divide" --> <!-- mode="divide2" --> <!-- mode="screen" --> <!-- mode="hard_light" --> > <!-- optional <RasterColorizer/> goes here --> </RasterSymbolizer> </Rule> </Style>
s = Style() r=Rule() r.symbols.append(RasterSymbolizer()) s.rules.append(r)