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


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.


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.