Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
shapefile to geojson in node.js with mapnik
var geojsonStream = require('geojson-stream');
var mapnik = require('mapnik');
var fs = require('fs');
var input = 'test/data/world_merc.shp';
var output = './out.geojson';
// set up geojson output stream
var fileOut = fs.createWriteStream(output);
var geojsonOut = geojsonStream.stringify();
// set up mapnik to read shapefile
var ds = new mapnik.Datasource({type:'shape',file:input});
var featureset = ds.featureset()
var feat =;
// read all features
while (feat) {
feat =;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment