I'm attempting to use TileStache with a Mapnik source to output what would largely be transparent raster tiles from a GEOTIFF. I'm having difficulty getting Mapnik to produce images with the proper transparency, though. My Mapnik XML file looks like

<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs">
    <Style name="style">
            <RasterSymbolizer />
    <Layer name="layer" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs">
            <Parameter name="type">gdal</Parameter>
            <Parameter name="file">/home/ainlaen/test.tif</Parameter>
            <Parameter name="nodata">0</Parameter>

I have tried setting the nodata values both in the XML and with GDAL. The image will appear with proper transparency when viewed in QGIS after having it set with GDAL, but will have a black background when rendered by Mapnik, regardless of nodata setting. I have tried rendering images directly using Mapnik, and the result is the same as when using TileStache, so I don't believe that's the problem. In addition, the tiles are not displayed in their proper positions, but that's probably best saved for a separate question.


It seems that nodata wasn't rendering as transparent because the alpha band wasn't properly set. First setting the nodata value with gdal and then expanding to rgba using gdal_translate gave me the results I was looking for. It'd be nice to not have to expand to rgba, but I'm not sure that it's possible to have working transparency with a color table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.