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


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 ?


asked 07 Feb '12, 14:00

MrX1's gravatar image

accept rate: 0%

Here's an example of parsing a .pbf file natively in Ruby:

permanent link

answered 07 Dec '16, 17:28

Richard's gravatar image

Richard ♦
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

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 ... 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, should be worth a look.

(11 Feb '12, 09:46) malenki

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: - 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 ♦
accept rate: 23%

edited 09 Feb '12, 07:23


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

(07 Feb '12, 14:38) MrX1

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

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

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: 07 Feb '12, 14:00

question was seen: 13,821 times

last updated: 07 Dec '16, 17:28

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