NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I am currently trying to extract data from a OpenStreetMap "osm.pbf"-file. This data should then be used for further processing. Currently, I managed to extract a desired location from a database file using osmosis. Now, I would like to convert this area in some data structure which I can manipulate (e.g. a graph, where each edge represents a street), so that I can insert / delete streets / buildings etc.

I found this post ,which gives some information about the pbf format for parsing. It says there, that there are Nodes/Ways/Relations and more, but I could not find any information, what a Node/Way/Relation represent or "mean". Therefore I am not completely sure, how to parse the file and extract the data I want. Are there any tutorials or sample code, which parses osm files and extract e.g. all streets in a certain location? I've seen a lot of different APIs - maybe there exist one, which converts the whole area into another datastructure - lets say e.g. a Java JGraph?

asked 23 Aug '13, 12:59

Pille456's gravatar image

accept rate: 0%

It's not a tutorial, but mkgmap is nicely-written (Java) code that understands PBF format files.

(23 Aug '13, 14:39) SomeoneElse ♦

In support of Vincent's answer.

It does not sound like you should be parsing PBF files. Your interest will be in the frameworks/libraries available for your language of choice. If you have skills with other geo data formats, you may want to use a conversion.

If you are going to stick to OSM data then understanding Nodes/Ways/Relations will be important. These are the primitive data types. The meaning of these primitives are dictated by the tags associated with them. So roads are identified by the value in the highway key.

Since you're interested in having a graph data structure for your roads it is likely you'll be looking for a conversions which relate to routing.

To answer the original question, the PBF Format is the tutorial for parsing PBF files. I did a blog entry describing my very basic parsing, it is basically the wiki page in code form.

permanent link

answered 23 Aug '13, 18:14

he_the_great's gravatar image

accept rate: 14%

First of all, you are expected to already be familliar with the OSM data structure. The wiki will tell you about nodes, ways, relations, and tags.

Second of all, you probably want to use one of the existing helper library instead of plain ProtocolBuffers. There are libraries for c++, python, ruby, javascript, and probably others. Follow the links for your tool of choice and you should find some tutorials.

permanent link

answered 23 Aug '13, 13:37

Vincent%20de%20Phily's gravatar image

Vincent de P... ♦
accept rate: 19%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 23 Aug '13, 12:59

question was seen: 17,625 times

last updated: 23 Aug '13, 18:14

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum