Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created June 1, 2018 01:26
Show Gist options
  • Save stepankuzmin/6954d7a45823bebd673d7323087e8745 to your computer and use it in GitHub Desktop.
Save stepankuzmin/6954d7a45823bebd673d7323087e8745 to your computer and use it in GitHub Desktop.

Count features in MVT tile

Usage:

npm i @mapbox/vector-tile
node count-features-in-tile.js tile.pbf
const fs = require("fs");
const Protobuf = require("pbf");
const VectorTile = require("@mapbox/vector-tile").VectorTile;
const args = process.argv.slice(2);
const data = fs.readFileSync(args[0]);
const tile = new VectorTile(new Protobuf(data));
const layers = tile.layers;
Object.keys(layers).forEach(layerId => {
const layer = layers[layerId];
console.log(layerId, layer.length);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment