Last active
June 7, 2016 19:17
-
-
Save morganherlocker/41ec7e2dc37ae86bffeb1bc9cd4401c9 to your computer and use it in GitHub Desktop.
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 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