Skip to content

Instantly share code, notes, and snippets.

@morganherlocker
Last active June 7, 2016 19:17
Show Gist options
  • Save morganherlocker/41ec7e2dc37ae86bffeb1bc9cd4401c9 to your computer and use it in GitHub Desktop.
Save morganherlocker/41ec7e2dc37ae86bffeb1bc9cd4401c9 to your computer and use it in GitHub Desktop.
var geojson2svg = require('geojson2svg');
var turf = require('turf');
var fs = require('fs')
var polys = require('polygons.json') // a featurecollection of geojson polygons with a name property
polys.features.forEach(function(poly){
var extent = turf.bbox(poly)
var options = {
viewportSize: {width: 200, height: 100},
mapExtent: {left: extent[0], bottom: extent[1], right: extent[2], top: extent[3]},
output: 'svg'
}
var converter = geojson2svg(options);
var svg = converter.convert(poly);
fs.writeFileSync(poly.properties.name+'.svg', svg)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment