RasterSymbolizer - plepe/mapnik GitHub Wiki
The RasterSymbolizer is used to render an image from any GDAL supported format using the GDAL plugin or from GeoTiff's using the Raster plugin.
-
Mapnik does not yet support on-the-fly reprojection of raster layers (like it does for vector layers)
-
Therefore it is necessary 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
| parameter | value | description |
|---|---|---|
| opacity | 0.0 - 1.0 | 1 is fully opaque while zero is fully transparent and .5 would be 50% transparent |
comp-op (previously called mode in <= Mapnik 2.0.x) |
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 two types of raster datasources: gdal or raster:
- 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.
See the GDAL plugin and Raster plugin pages for more info
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)FIXME
