Skip to content

Instantly share code, notes, and snippets.

@mapsam
Created March 1, 2016 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mapsam/1db56dbba4c37756fdfc to your computer and use it in GitHub Desktop.
Save mapsam/1db56dbba4c37756fdfc to your computer and use it in GitHub Desktop.
node-mapnik usage example
var fs = require('fs');
var map = new mapnik.Map(256, 256),
img = new mapnik.Image(256, 256),
data = fs.readFileSync('/path/to/data.shp'),
vectortile = new mapnik.VectorTile(0,0,0);
// add shapefile to vector tile
vectortile.addData(data, function(err) {
if (err) throw err;
// render data to an image
vectortile.render(map, image, function(err, image) {
if (err) throw err;
// save image
image.save('/path/to/newimage.png', 'png32');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment