I used mapnik_node_tile_server to generate tiles from a shapefile created by gdal_contour. The tile generation function is:

function fetchTile(layer, z, x, y, callback) {
  var map = new mapnik.Map(TILE_SIZE, TILE_SIZE); // TILE_SIZE = 256
  var layerPath = util.format('%s/layers/%s.xml', __dirname, layer);
  var tileFilePath = util.format('%s/tiles/%s/%d/%d/%d.png', __dirname, layer, z, x, y)
  var cachedTile = getCachedTile(tileFilePath);
  if (cachedTile) {
  } else {
    var filePath = util.format('%s/tiles/%s/%d/%d/', __dirname, layer, z, x);
    map.zoomToBox(mercator.bbox(x, y, z, false, '900913'));
    var im = new mapnik.Image(TILE_SIZE, TILE_SIZE);
    map.render(im, function(err, im) {
      if (err) console.log('error', err);
      file = im.saveSync(tileFilePath, 'png');


Most of the contour lines are not rendered in the tiles and transparent areas are not created correctly. Here is the shapefile drawn in QGIS and generated tiles in CesiumJS respectively. enter image description here


1 Answer 1


The reason was in mapnik style xml, I forgot to remove this line

<PolygonSymbolizer fill="white"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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