Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created October 30, 2024 15:31
Show Gist options
  • Save stepankuzmin/b93723a892cb6709bbcb6c18e7028f35 to your computer and use it in GitHub Desktop.
Save stepankuzmin/b93723a892cb6709bbcb6c18e7028f35 to your computer and use it in GitHub Desktop.
Extract tile from mbtiles
/* 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