Created
March 1, 2016 01:58
-
-
Save mapsam/1db56dbba4c37756fdfc to your computer and use it in GitHub Desktop.
node-mapnik usage example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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