LinuxCommandLibrary

osmium

Process and convert OpenStreetMap data

TLDR

Show file information

$ osmium fileinfo [path/to/input.osm]
copy

Display contents
$ osmium show [path/to/input.osm]
copy

Convert file format from PBF into XML
$ osmium cat [path/to/input.osm.pbf] [[-o|--output]] [path/to/output.osm]
copy

Extract a geographic region by the given [b]ounding box
$ osmium extract [[-b|--bbox]] [min_longitude],[min_latitude],[max_longitude],[max_latitude] [path/to/input.pbf] [[-o|--output]] [path/to/output.pbf]
copy

Extract a geographic region by a GeoJSON file
$ osmium extract [[-p|--polygon]] [path/to/polygon.geojson] [path/to/input.pbf] [[-o|--output]] [path/to/output.pbf]
copy

Filter all objects tagged as "restaurant"
$ osmium tags-filter [path/to/input.pbf] amenity=restaurant [[-o|--output]] [path/to/output.pbf]
copy

Filter for "way" objects tagged as "highway"
$ osmium tags-filter [path/to/input.pbf] w/highway [[-o|--output]] [path/to/output.pbf]
copy

Filter "way" and "relation" objects tagged as "building"
$ osmium tags-filter [path/to/input.pbf] wr/building [[-o|--output]] [path/to/output.pbf]
copy

SYNOPSIS

osmium subcommand [options] [arguments]
Example: osmium fileinfo input.osm.pbf
Example: osmium extract --bbox -1.0,50.0,1.0,51.0 input.osm.pbf -o output.osm.pbf

PARAMETERS

subcommand
    Specifies the primary operation to perform. Each subcommand has its own specific options and arguments.

fileinfo
    Displays detailed information about an OpenStreetMap (OSM) file, including header data, object counts, and bounding box.

extract
    Extracts a subset of OSM data from a larger file based on criteria such as a bounding box, polygon, or a list of IDs.

tags-filter
    Filters OSM objects (nodes, ways, relations) based on their tags, allowing for precise data selection.

cat
    Concatenates multiple OSM input files into a single output file, with optional filtering.

sort
    Sorts an OSM file by object ID or by geographical location, which can optimize subsequent processing steps.

diff
    Compares two OSM files and outputs the differences as an OSM change file (.osc).

apply-changes
    Applies changes specified in an OSM change file (.osc) to an existing OSM data file.

-h, --help
    Displays help information for the main command or a specified subcommand.

-v, --version
    Displays the version of the Osmium Tool being used.

--verbose
    Enables verbose output, providing more detailed information during processing.

--progress
    Displays a progress bar for long-running operations.

DESCRIPTION

Osmium Tool is a versatile command-line utility designed for high-performance manipulation of OpenStreetMap (OSM) data. Built upon the efficient libosmium C++ library, it enables users to perform a wide array of operations on OSM data files in various formats, including PBF, XML, and O5M. Its capabilities encompass reading, writing, filtering, extracting subsets, sorting, and diffing OSM datasets.

It is an essential tool for GIS professionals, researchers, and developers who need to process, analyze, or convert large volumes of OSM data. Osmium Tool excels in handling planet-scale datasets efficiently due to its streaming architecture and optimized data structures, making it a cornerstone for many OSM data workflows, from simple format conversions to complex geographical extractions and data validation tasks.

CAVEATS

Osmium Tool is highly optimized for performance and memory efficiency, especially when dealing with very large OpenStreetMap datasets (e.g., planet files). However, processing extremely large files still requires significant RAM, potentially tens of gigabytes. It is primarily a command-line tool, and while powerful, it lacks a graphical user interface. Users should be familiar with command-line operations and basic OpenStreetMap data structures. Installation typically requires compiling from source or using package managers on specific Linux distributions (e.g., osmium-tool package).

SUPPORTED FORMATS

Osmium Tool supports various OSM file formats including PBF (Protocol Buffer Binary Format), XML (.osm), O5M/O5C, and can often output to CSV or JSON for specific data types. PBF is generally the most efficient format for large inputs and outputs.

STREAMING PROCESSING

Many Osmium operations are designed to work in a streaming fashion. This allows the tool to process very large datasets, such as the full OSM planet file, without needing to load the entire dataset into memory simultaneously, significantly reducing memory footprint for large tasks.

HISTORY

The Osmium library and subsequently the Osmium Tool were developed by Jochen Topf. Osmium originated as a high-performance C++ library (libosmium) designed to efficiently parse, read, and write OpenStreetMap PBF (Protocol Buffer Binary Format) files, which are the most common and efficient format for distributing OSM data. The Osmium Tool was built on top of libosmium to provide a user-friendly command-line interface for common OSM data manipulation tasks. Its development has been driven by the need for faster and more memory-efficient processing of the ever-growing OpenStreetMap dataset, becoming a staple in many OSM data workflows since its inception.

SEE ALSO

osmosis(1), osmconvert(1), ogr2ogr(1)

Copied to clipboard