0

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 http://wiki.openstreetmap.org/wiki/PBF_Format ,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

Pille456
16223
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 ♦

2 Answers:
3

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

he_the_great
1.2k61423
accept rate: 14%

4

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... ♦
17.0k16147244
accept rate: 19%

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×585
×51
×17
×16

question asked: 23 Aug '13, 12:59

question was seen: 12,008 times

last updated: 23 Aug '13, 18:14

powered by OSQA