Converting .pbf file to .osm using pyosmium

1.4k views Asked by At

I have downloaded a rather large file from geofabrik.de and it is in the form of a pbf. I need to convert it into an osm file so I can extract the nodes and edges from the file. I have downloaded the osmium library by using pip install osmium but it just gives me an error

ModuleNotFoundError: No module named 'osmium'

Can someone help me with how to use osmium please?

1

There are 1 answers

0
Tordanik On

It's useful to make a distinction between the Osmium Tool (a command-line application) and the Osmium Library. The latter is what you use to access OSM data in your own code, and it comes in various flavours for different programming languages – such as pyosmium for Python.

Converting .osm.pbf to .osm uses only built-in functionality of Osmium and does not involve writing your own code, so you can achieve it by calling the command-line tool with the appropriate parameters:

osmium cat luxembourg-latest.osm.pbf -o luxembourg-latest.osm

For your module error, it may be better to ask a separate question. But one thing to check is that you're using the correct version of python – simply calling python3 instead of python may make a difference depending on your system.