Created
October 30, 2024 15:31
-
-
Save stepankuzmin/b93723a892cb6709bbcb6c18e7028f35 to your computer and use it in GitHub Desktop.
Extract tile from mbtiles
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
/* eslint-disable handle-callback-err */ | |
import fs from 'fs'; | |
import zlib from 'zlib'; | |
import MBTiles from '@mapbox/mbtiles'; | |
const z = 0; | |
const x = 0; | |
const y = 0; | |
// tippecanoe -f -z0 -o admin.mbtiles admin.geojson | |
new MBTiles('./admin.mbtiles', (err, mbtiles) => { | |
mbtiles.getTile(z, x, y, (err, data) => { | |
zlib.unzip(data, (err, buffer) => { | |
fs.writeFileSync(`./admin-${z}-${x}-${y}.vector.pbf`, buffer); | |
console.log('Done'); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment