Dylan
Dylan

Reputation: 9383

Read openstreetmap PBF file with PHP?

I downloaded a mbtiles file from this location: https://openmaptiles.com/downloads/europe/netherlands/

I can serve this file in PHP with this library : https://github.com/klokantech/tileserver-php

This returns a compressed PBF, which Mapbox GL JS can use, but I'm not able in PHP to decode this data to get information out of it.

Has anybody ever extracted data from PBF using PHP ?

Upvotes: 3

Views: 1652

Answers (1)

whiskeY11
whiskeY11

Reputation: 61

I know that this thread is a little bit old right now, but I will answer this anyway in case someone bumps into this issue.

You can use package named osm-pbf, for reading PBF files using PHP. As far as I know, it is currently the only option if you want to use PHP.

Link to package: https://github.com/franksierra/osm-pbf

Installation is fairly easy, you can just use composer.

The library itself is pretty slow, it takes around 8 minutes to read 300MB PBF file, but for smaller files it works like a charm.

Upvotes: 1

Related Questions