How can I parse *.vector.pbf about Mapbox vector tile map?

kevin4z picture kevin4z · Mar 16, 2016 · Viewed 7.3k times · Source
  1. *.pbf("Protocolbuffer Binary Format") is primarily intended as an alternative to the XML format.
  2. There are two formats of *.osm.pbf and *.vector.pbf. What tools can I use to open these files? (I know JOSM can open *.osm.pbf files, but it can't open *.vector.pbf files.)
  3. If I want to write own *.vector.pbf files in Mapbox, how do I work for that?

Thanks!

Answer

Cyrille picture Cyrille · Jan 12, 2020

Regarding question #2, extracting PBF data

Using GDAL's ogr2ogr is the easiest method (I found). Given a file named 1583.vector.pbf decode it to a, for example, shapefile (folder) named output:

# cmd   show prog.  output format     output name     input name
ogr2ogr -progress -f "ESRI Shapefile" output          1583.vector.pbf 

Regarding question #3, creating PBF data

Use the same command as above but swap the input/outputs and output format:

# example source: https://gdal.org/drivers/vector/mvt.html
ogr2ogr -f MVT mytileset source.gpkg -dsco MAXZOOM=10