LinuxCommandLibrary

osmium

command-line tool for working with OpenStreetMap data

TLDR

Extract area from OSM file

$ osmium extract -b [left],[bottom],[right],[top] [input.osm.pbf] -o [output.osm.pbf]
copy
Convert format
$ osmium cat [input.osm.pbf] -o [output.osm.xml]
copy
Merge multiple files
$ osmium merge [file1.osm.pbf] [file2.osm.pbf] -o [merged.osm.pbf]
copy
Filter by tags
$ osmium tags-filter [input.osm.pbf] -o [output.osm.pbf] [nwr/highway]
copy
Show file info
$ osmium fileinfo [file.osm.pbf]
copy
Check file integrity
$ osmium check-refs [file.osm.pbf]
copy
Sort OSM data
$ osmium sort [input.osm] -o [sorted.osm]
copy
Get difference between files
$ osmium diff [old.osm.pbf] [new.osm.pbf]
copy

SYNOPSIS

osmium command [-o output] [options] files

DESCRIPTION

osmium is a command-line tool for working with OpenStreetMap data. It processes, filters, and transforms OSM files efficiently.
Extract creates regional subsets from larger files. Bounding boxes define rectangular areas. Polygon files enable extraction of complex shapes like administrative boundaries.
Tags-filter creates files containing only specific feature types. Tag expressions select highways, buildings, points of interest, or custom combinations.
Merging combines multiple files into one, handling overlapping data correctly. Files must be sorted for merging. The sort command prepares unsorted data.
Format conversion handles PBF (Protocol Buffer Binary), OSM XML, and OPL (Object Per Line) formats. PBF is compressed and efficient; XML is human-readable.
Diff shows changes between file versions, useful for tracking map edits over time.

PARAMETERS

cat

Concatenate/convert files.
extract
Extract region from file.
merge
Merge sorted files.
tags-filter
Filter by tags.
sort
Sort OSM data.
diff
Compare files.
fileinfo
Show file information.
check-refs
Check referential integrity.
-o FILE
Output file.
-b BBOX
Bounding box (left,bottom,right,top).
-p POLYGON
Polygon file for extraction.
--overwrite
Overwrite existing output.
-f FORMAT
Output format.
-v, --verbose
Verbose output.

CAVEATS

Large files require significant memory. Some operations need sorted input. Extraction may include incomplete relations. Complex filters have learning curve.

HISTORY

osmium and the libosmium library were developed by Jochen Topf starting around 2013. It became the standard command-line tool for OSM data processing, replacing older tools with better performance and reliability.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community