TransWikia.com

Incorrect tiles from a shapefile are generated by mapnik

Geographic Information Systems Asked by David Osipyan on August 3, 2021

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) {
    callback(cachedTile);
  } else {
    var filePath = util.format('%s/tiles/%s/%d/%d/', __dirname, layer, z, x);
    mkdirp.sync(filePath);
    map.loadSync(layerPath);
    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');
      callback(fs.readFileSync(tileFilePath));
    });
  }

}

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

d

One Answer

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

<PolygonSymbolizer fill="white"/>

Answered by David Osipyan on August 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP