Hello, how do I open and parse a .osm.pbf file?

Hello,

I’m making a Pokemon Go competitor which has a more complex battle system, and overland will be like Master of Magic or Risk.

I would like to open and read a .osm.pbf file in Java.

I’m a noob to .osm.pbf files.

Is it possible to do stuff like find all buildings around a GPS coordinate?

Other than buildings, what objects are mapped?

All I really want is to be able to know how to read and parse a .osm.pbf file. Are they .txt or binary?

Any help is appreciated.

,Jim

Osmosis is a possible tool to help you with reading .osm.pbf files.

What is mapped ? Maybe it is better to ask what is not mapped :slight_smile:
roads, railways, rivers, parks, landuse, POIs, etc. etc.

See the Map Features page on the wiki to get an idea what is being mapped. That does not mean that all features are mapped in all places. Some countries are better mapped than others.

If you need to ask whether the file is text or binary, why not use the .osm files instead.

Also, to add to the comment about variability in detail,detail can very on a scale of 10s to 100s of metres, not just on a national scale. For a feature to get mapped, someone who has an interest in that feature needs to take interest in an area.

osm.pbf is bynary format, but heavy based on key-values what comes from XM world.
You must use Google’s protobuffer library to read internal structures.
Planet.osm.pbf not contain any indexes, so if you want “find near objects”, you need to process around 36gb of data.

1 Like

osm.pbf is binary where .pbf means Googles Protocol Buffers format which is but fairly simple.
You should take a look at how the .osm.pbf messages are structured and what they contain here:
https://wiki.openstreetmap.org/wiki/PBF_Format
And before that how the messages are encoded in binary here:

They are block pairs that begin with a big endian 4B int describing the blocks content length and the content is then googles pbf that contains various info, the content may be and usually is compressed so you’d need zlib decode first.