12

I am working on Google Maps with AirMap API. AirMap API provides me with vector tile data in pbf-format.

I want to render it into Google Maps. I have researched that to render pbf vector tiles on Google Map, I need to convert it into GeoJSON data. I have a lot researched about it but I haven't found any tool to convert PBF to GeoJson or tutorial. Any suggestions about how to?

4
  • OSM PBF can be converted to OSM XML. There should be multiple OSM XML to GeoJSON converters available.
    – scai
    Sep 20, 2017 at 13:35
  • @scai, Thank you for your reply. I have tried many tools like OSMCONVERT, OGR2OGR and OSMOSIS. But my bad luck, it shows me "Invalid file format". Sep 20, 2017 at 14:12
  • You can also try osmium. If all tools fail then this is probably not an OSM PBF file. I guess it is a MapBox-specific format. Not sure how to handle this.
    – scai
    Sep 20, 2017 at 14:13
  • 1
    @scai, Yes you are right. It could be mapbox specific format. Sep 21, 2017 at 6:44

5 Answers 5

10

Your data seems to be Mapbox Vector Tiles in pbf format.

GDAL 2.3 can process this data: https://www.gdal.org/drv_mvt.html

Note that MB tiles and OSM pbf files are something completely different.

1
  • +1 for clarifying the difference between different pbf! I got confused for a long time. The link you provided is also very helpful.
    – hxd1011
    Sep 8, 2019 at 10:04
4

You can use tippacanoe-decode to convert PBF files to GeoJSON.

https://github.com/mapbox/tippecanoe#tippecanoe-decode

3

No, You can not.

Why? click here for details

https://transparentgov.net/cleargov1/940/pbf-not-work-with-mapserver-but-work-with-featureserver

Mapbox vector tile is different from PBF, even MBTile use PBF format.

Let me explain, PBF is a compressed format for json. You can zip json, you can PBF json, the difference is zipped json larger in size, you can get only the data you need from a pbf json, without parse whole dataset.

mapbox vector tile, '.mbtile' is a set of data, not a single piece of data

you are trying to convert a bunch of dataset into a single piece of geojson, it is not possible( possible by previous answers above), even possible, but does not make sense. You try to convert a few piece of tile into a geojson? does not make any sense, since a few tile maybe contain a cutted partial of a polygon, line, these cutted partial polygon or line can't be a geojson.

The only case it possible is if you try to convert a single piece pbf to a single piece of geojson.

For example, arcgis REST api, you can use http URL like

          '...?f=pbf' 

instead of

          '...?f=json', 

you will get a single piece of response from .xhr,

you can use mapbox pbf to unzip pbf back to json.

Here is a tool to convert ESRI pbf format into json

https://github.com/rowanwins/arcgis-pbf-parser

Here is ESRI pbf format

https://github.com/Esri/arcgis-pbf/tree/main/proto/FeatureCollection

Here is a library for retrieving features from an ArcGIS FeatureServer or MapServer. This library makes tiled requests rather than simply requesting every feature.

https://github.com/rowanwins/mapbox-gl-arcgis-featureserver

1

You can use QGIS to load your .pbf file and once you drag and drop the file on QGIS the data will be displayed as a layer on map, then:

Right click on the layer > Save as > Change format Format: GeoJSON, choose the layer name and set COORDINATE_PRECISION=5 (recommended).

And done! Your pbf file is converted to GeoJSON.

Or you can use ogr2ogr, which is a commandline tool for converting osm to GeoJson.

2
0

I recently created a JavaScript library to load vector tiles (pbf) in Google Maps. https://github.com/techjb/Vector-Tiles-Google-Maps

Hope it will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.