LinuxCommandLibrary

osmconvert

TLDR

Convert PBF to OSM XML

$ osmconvert [input.pbf] -o=[output.osm]
copy
Convert OSM to PBF
$ osmconvert [input.osm] -o=[output.pbf]
copy
Extract bounding box
$ osmconvert [input.pbf] -b=[lon1,lat1,lon2,lat2] -o=[output.pbf]
copy
Filter by polygon
$ osmconvert [input.pbf] -B=[polygon.poly] -o=[output.pbf]
copy
Merge files
$ osmconvert [file1.pbf] [file2.pbf] -o=[merged.pbf]
copy
Show statistics
$ osmconvert [input.pbf] --out-statistics
copy

SYNOPSIS

osmconvert [options] input... [-o=output]

DESCRIPTION

osmconvert converts and filters OpenStreetMap data files. It handles conversion between OSM XML, PBF, and O5M formats, and can extract regions by bounding box or polygon.
Much faster than osmosis for simple conversions.

PARAMETERS

-o file

Output file.
-b bbox
Bounding box filter.
-B file
Polygon file filter.
--drop-author
Remove author info.
--drop-version
Remove version info.
--complete-ways
Keep complete ways.
--out-statistics
Show statistics.

BOUNDING BOX FORMAT

$ -b=min_lon,min_lat,max_lon,max_lat
-b=-74.1,40.5,-73.7,40.9  # NYC area
copy

CAVEATS

Memory-intensive for large files. Polygon files in .poly format. PBF format most efficient.

HISTORY

osmconvert was developed by Markus Weber as a fast alternative to osmosis for common OSM data manipulation tasks.

SEE ALSO

Copied to clipboard