Created
August 16, 2019 22:35
Star
You must be signed in to star a gist
Convert a directory of vector tiles to GeoJSON.
This file contains 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
const fs = require('fs'); | |
const vt2geojson = require('@mapbox/vt2geojson'); | |
const glob = require('glob'); | |
glob('tiles/**/*.pbf', {}, function (er, files) { | |
files.forEach((path) => { | |
const [_, z, x, y] = path.match(/^tiles\/(\d+)\/(\d+)\/(\d+)\.pbf/); | |
console.log(`x: ${x}`); | |
vt2geojson({ | |
uri: `tiles/${z}/${x}/${y}.pbf`, | |
layer: 'no2', | |
z, | |
x, | |
y, | |
}, function (err, result) { | |
if (err) throw err; | |
fs.writeFileSync(`tiles/${z}/${x}/${y}.geojson`, JSON.stringify(result)); | |
console.log(`Wrote tiles/${z}/${x}/${y}.geojson.`) | |
}); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment