🆕Working with OpenStreetMap files

Converting PBF to OSM XML

A lot of routing software used in the OpenStreetMap (OSM) project supports Protocolbuffer Binary Format (PBF). There are several tools to convert from PBF to OSM XML and vice versa if required.





Lightweight (but fast) application to convert and process OSM files.


osmconvert OSMulti-modalRoutingNetwork.pbf >OSMulti-modalRoutingNetwork.osm

Command line application for processing OSM data.


osmosis --read-pbf OSMulti-modalRoutingNetwork.pbf --write-xml OSMulti-modalRoutingNetwork.osm

Multipurpose command line tool based on the Osmium Library.


osmium OSMulti-modalRoutingNetwork.pbf -o OSMulti-modalRoutingNetwork.osm

Sorting OSM files

OSM files are usually sorted in a specific way: first the nodes ordered by ID, then ways ordered by ID, then relations ordered by ID. But this is not necessarily so.

To check if a file is sorted, in Osmium use fileinfo :

> osmium fileinfo -e input.osm.pbf
Objects ordered (by type and id): yes

Many commands only work correctly if the file is sorted.

To sort a file using Osmium:

> osmium sort input.osm.pbf -o output.osm.pbf

To sort a file using Osmosis:

osmosis --read-pbf input.osm.pbf --sort --write-pbf output.osm.pbf

Last updated