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

Hi,

How can I parse(read) a binary *.pbf extract of a country ? Do I need some additional software or I can do it with standard functions of any programming language ?

Thanks

asked 07 Feb '12, 14:00

MrX1's gravatar image

MrX1
467711
accept rate: 0%


Well in theory you can use any programming language to parse the data without the help of any libraries. Here's a C program that does exactly that: http://m.m.i24.cc/osmconvert.c - the more usual way, however, is to use a Google Protocol Buffer library to parse the data. Ready-made OSM reading modules exist for Java, Python, and for C++ ("Osmium") among others.

permanent link

answered 07 Feb '12, 14:04

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

edited 09 Feb '12, 07:23

2

Frederik it's amazing how quickly you create useful answer for any question. Well done. Thank you

(07 Feb '12, 14:38) MrX1
1

The wiki page for osmconvert is also worth a read - it has links to various binary versions too.

(06 Jul '12, 11:56) SomeoneElse ♦

Here's an example of parsing a .pbf file natively in Ruby: https://github.com/systemed/ruby_osmpbf

permanent link

answered 07 Dec '16, 17:28

Richard's gravatar image

Richard ♦
30.9k44279412
accept rate: 18%

You can download Osmosis.

In the bin directory

drop your pbf file

Create a run.bat file in notepad with following commands all on one line :

osmosis --read-pbf my_map.osm.pbf --write-xml my_map.osm

save bat file in the same folder and dble click on it

this will create your new osm file

Read instructions for more more detailed commands

permanent link

answered 07 Feb '12, 17:17

wilpin's gravatar image

wilpin
371
accept rate: 0%

The question of MrX1 was about parsing a PBF file for own purposes, maybe with an own program.

Your way would be correct if you just wanna convert a PBF into an OSM file. This can also be done with http://wiki.openstreetmap.org/wiki/Osmconvert ... maybe even in a more simple way.

(08 Feb '12, 16:35) stephan75

When the user reads the instructions as recommended, he'll see that with Osmosis he can also manipulate the data. Additionally, maybe Osmembrane should be mentioned, a GUI for osmosis.

Plus, http://wiki.openstreetmap.org/wiki/Osmfilter should be worth a look.

(11 Feb '12, 09:46) malenki

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

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:

×83
×6

question asked: 07 Feb '12, 14:00

question was seen: 14,311 times

last updated: 07 Dec '16, 17:28

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