### Get Help for Osmium Subcommand Source: https://osmcode.org/osmium-tool/manual.html Use `osmium COMMAND -h` to get a short description of a subcommand's options. ```bash osmium COMMAND -h ``` -------------------------------- ### Get basic file information Source: https://osmcode.org/osmium-tool/manual.html Use 'osmium fileinfo' to display basic information about an OSM file, such as format, compression, and size. ```bash osmium fileinfo OSMFILE ``` ```bash osmium fileinfo liechtenstein-latest.osm.pbf ``` -------------------------------- ### Display Osmium Manual Page Source: https://osmcode.org/osmium-tool/manual.html Use `osmium help COMMAND` to display the manual page explaining all details of a subcommand. Alternatively, use the system's `man` command if Osmium is installed. ```bash osmium help COMMAND ``` ```bash man osmium man osmium-fileinfo ``` -------------------------------- ### Get extended file information Source: https://osmcode.org/osmium-tool/manual.html Use the '-e' or '--extended' flag with 'osmium fileinfo' to read the whole file and get more detailed information from the header and data sections. ```bash osmium fileinfo -e liechtenstein-latest.osm.pbf ``` -------------------------------- ### Filter by Tag Key Prefix Source: https://osmcode.org/osmium-tool/manual.html Finds all nodes with tags whose keys start with 'addr:'. Useful for selecting address-related information. ```bash n/addr:* ``` -------------------------------- ### Get OSM Objects by ID Source: https://osmcode.org/osmium-tool/manual.html Retrieves specific OSM nodes, ways, or relations by their IDs from an input file. ```bash osmium getid input.osm.pbf n17 n18 w42 r3 -o output.osm.pbf ``` ```bash osmium getid input.osm.pbf -i ids -o output.osm.pbf ``` ```bash echo "r123 foo bar" | osmium getid input.osm.pbf -i - -f debug ``` ```bash osmium getid -r input.osm.pbf w222 -o output.osm.pbf ``` -------------------------------- ### Get specific data from OSM file Source: https://osmcode.org/osmium-tool/manual.html Use the '-g' or '--get' option with 'osmium fileinfo' to extract a specific piece of information, like the last timestamp or CRC32 checksum. ```bash osmium fileinfo -e -g data.timestamp.last liechtenstein-latest.osm.pbf ``` ```bash checksum=$(osmium fileinfo -e -g data.crc32 $filename) ``` -------------------------------- ### Filter Ways with 'highway' Tag Source: https://osmcode.org/osmium-tool/manual.html Extracts all ways tagged with 'highway' from an OSM file. Use this to get all road-like features. ```bash osmium tags-filter rome.osm.pbf w/highway \ -o highways-in-rome.osm.pbf ``` -------------------------------- ### Filter History File by Tags and Get IDs Source: https://osmcode.org/osmium-tool/manual.html Filters a history file for nodes with a specific tag, then retrieves the IDs of these nodes and their history from the original file. ```bash osmium tags-filter input.osh.pbf n/shop -o out.osh.pbf osmium getid --id-osm-file out.osh.pbf --with-history input.osh.pbf -o filtered.osh.pbf ``` -------------------------------- ### Filter Ways Without Referenced Nodes Source: https://osmcode.org/osmium-tool/manual.html Finds ways named with something starting with 'Via' but excludes the nodes required to draw them. Use the `-R` or `--omit-referenced` option when only the ways themselves are needed. ```bash osmium tags-filter rome.osm.pbf -R name=Via* \ -o via.osm.pbf ``` -------------------------------- ### Force input/output file formats Source: https://osmcode.org/osmium-tool/manual.html Demonstrates forcing input and output file formats using `-f` and `-F` options, which is particularly useful when reading from STDIN or writing to STDOUT. The format is specified using the file suffix. ```bash osmium cat input.osm.pbf -f osm | some_program_reading_osm_xml ``` -------------------------------- ### Show OSM file contents Source: https://osmcode.org/osmium-tool/manual.html Use the 'osmium show' command to display the contents of an OSM file in a human-readable debug format, paginated by default. ```bash osmium show liechtenstein-latest.osm.pbf ``` -------------------------------- ### Display Osmium Command List Source: https://osmcode.org/osmium-tool/manual.html Calling the `osmium` command without any arguments lists all available subcommands. ```bash osmium ``` -------------------------------- ### Clone Osmium Tool Repository Source: https://osmcode.org/osmium-tool/manual.html Clone the Osmium Tool repository from GitHub to build from source. ```bash git clone https://github.com/osmcode/osmium-tool ``` -------------------------------- ### Filter Changesets by Date Range and User Source: https://osmcode.org/osmium-tool/manual.html Filters changesets within a specific date range and then uses grep to select changesets by listed users. Outputs in OPL format. ```bash osmium changeset-filter -a 2015-01-01T00:00:00Z -b 2015-01-31T23:59:59Z \ -f opl | grep ' u\(foo\|bar\|baz\) ' ``` -------------------------------- ### Create Multiple Extracts with Config File Source: https://osmcode.org/osmium-tool/manual.html Use this command to create multiple extracts defined in a JSON configuration file. The output file names are specified within the config. ```bash osmium extract -c departments.json france.pbf ``` -------------------------------- ### Convert PBF to bzip2 compressed XML Source: https://osmcode.org/osmium-tool/manual.html Converts a Liechtenstein PBF file to an XML format compressed with bzip2. Osmium automatically detects the file format based on the file name. ```bash osmium cat liechtenstein-latest.osm.pbf -o liechtenstein.osm.bz2 ``` -------------------------------- ### Smart Strategy Options Source: https://osmcode.org/osmium-tool/manual.html Customize the 'smart' extraction strategy to include specific relation types beyond multipolygons. Use '-S types=any' for all relation types or specify comma-separated types. ```bash osmium extract -S types=multipolygon,route -c config.json input.pbf ``` -------------------------------- ### Filter by Tag Key and Value (Shorthand) Source: https://osmcode.org/osmium-tool/manual.html A shorthand for filtering objects by tag key and value, equivalent to 'nwr/amenity=restaurant'. ```bash amenity=restaurant ``` -------------------------------- ### JSON Configuration for Multiple Extracts Source: https://osmcode.org/osmium-tool/manual.html This JSON structure defines the output directory and a list of extracts to be created. Each extract specifies an output file and a polygon source (e.g., GeoJSON). ```json { "directory": "/tmp/", "extracts": [ { "output": "dep01-ain.osm.pbf", "polygon": { "file_name": "dep01-ain.geojson", "file_type": "geojson" } }, { "output": "dep02-aisne.osm.pbf", "polygon": { "file_name": "dep02-aisne.geojson", "file_type": "geojson" } }, ... ] } ``` -------------------------------- ### Convert to compressed XML without metadata Source: https://osmcode.org/osmium-tool/manual.html Creates a bzip2-compressed XML file without metadata, resulting in a more compact format. Options for the file format can be added separated by commas. ```bash osmium cat input.osm.pbf -o output.osm.bz2 -f osm.bz2,add_metadata=false ``` -------------------------------- ### Download Relation Data from OSM API Source: https://osmcode.org/osmium-tool/manual.html Fetches full relation data, including members and their referenced nodes/ways, from the OSM API. ```bash https://www.openstreetmap.org/api/0.6/relation/RELATION-ID/full ``` ```bash https://www.openstreetmap.org/api/0.6/relation/7444/full ``` -------------------------------- ### Filter Changesets by User Source: https://osmcode.org/osmium-tool/manual.html Selects changesets from a compressed file that belong to a specific user. The output is also compressed. ```bash osmium changeset-filter -u Einstein changesets.osm.bz2 -o einstein.osm.bz2 ``` -------------------------------- ### Filter Nodes, Ways, and Relations by Tag Source: https://osmcode.org/osmium-tool/manual.html Finds objects (nodes, ways, or relations) tagged with 'amenity=restaurant'. This is a broader search for points of interest that can be represented as areas. ```bash nwr/amenity=restaurant ``` -------------------------------- ### Filter Nodes by Tag Key and Value Source: https://osmcode.org/osmium-tool/manual.html Finds all nodes tagged with 'amenity=restaurant'. This targets specific points of interest. ```bash n/amenity=restaurant ``` -------------------------------- ### Enable verbose mode Source: https://osmcode.org/osmium-tool/manual.html Enables verbose mode using the `-v` or `--verbose` option. This displays detailed information about command line parameters, execution steps, and memory usage to STDERR, with each output line prefixed by elapsed time. ```bash osmium --verbose cat input.osm.pbf ``` -------------------------------- ### Create Geographic Extract using Relation Boundary Source: https://osmcode.org/osmium-tool/manual.html Creates a geographic extract using a boundary defined by an OSM file containing a relation and its members. ```bash osmium extract -p paris-boundary.osm france.pbf -o paris.pbf ``` -------------------------------- ### Filter Objects by Multiple Tag Expressions Source: https://osmcode.org/osmium-tool/manual.html Combines filters for wooded areas, selecting objects tagged as either 'natural=wood' or 'landuse=forest'. Useful for gathering related features. ```bash osmium tags-filter park.osm.pbf wr/natural=wood wr/landuse=forest \ -o wooded-areas.osm.pbf ``` -------------------------------- ### Create Geographic Extract by Bounding Box Source: https://osmcode.org/osmium-tool/manual.html Extracts OSM data within a specified bounding box from an input file. ```bash osmium extract -b 2.25,48.81,2.42,48.91 france.pbf -o paris.pbf ``` -------------------------------- ### Sort an OSM File Source: https://osmcode.org/osmium-tool/manual.html Sorts an OSM file according to the standard order (nodes, ways, relations by ID). Be aware of high memory usage for large files. ```bash osmium sort input.osm.pbf -o output.osm.pbf ``` -------------------------------- ### Check Referential Integrity Source: https://osmcode.org/osmium-tool/manual.html Verifies if all referenced objects (nodes in ways) exist within the OSM file. Use -r to also check relation members. ```bash osmium check-refs input.osm.pbf ``` -------------------------------- ### Derive Change File from Two Data Files Source: https://osmcode.org/osmium-tool/manual.html Use `osmium derive-changes` to create a change file that represents the differences between two OSM data files. This command is used to generate change files for updating databases or tracking changes over time. ```bash osmium derive-changes yesterday.osm.pbf today.osm.pbf \ -o changes-since-yesterday.osc ``` -------------------------------- ### Merge Change Files Source: https://osmcode.org/osmium-tool/manual.html Use `osmium merge-changes` to combine multiple change files into a single file. The `--simplify` option is recommended to remove intermediate versions of objects. ```bash osmium merge-changes --simplify ch456.osc.gz ch457.osc.gz \ -o merged-changes.osc.gz ``` -------------------------------- ### Filter Nodes by Multiple Tag Keys and Values Source: https://osmcode.org/osmium-tool/manual.html Finds nodes with either the 'name' tag or the 'name:en' tag set to 'London'. Useful for locating places with specific names. ```bash n/name,name:en=London ``` -------------------------------- ### Apply Change Files to Data File Source: https://osmcode.org/osmium-tool/manual.html Use `osmium apply-changes` to update a data file with one or more change files. This command can also be used with history files by specifying the `--with-history` option or using `.osh` file extensions. ```bash osmium apply-changes planet.osm.pbf change-123.osc.gz change-124.osc.gz \ -o planet-new.osm.pbf ``` ```bash osmium apply-changes australia.osh.pbf australia-changes.osc.bz2 \ -o australia-new.osh.pbf ``` ```bash osmium apply-changes australia.osh.pbf australia-changes.osc.bz2 \ --with-history -o australia-new.osh.pbf ``` -------------------------------- ### Concatenate and filter by object type Source: https://osmcode.org/osmium-tool/manual.html Concatenates input files and filters to only copy objects of a specified type, such as 'node'. This command effectively merges and filters OSM data. ```bash osmium cat input.osm.pbf -t node -o output.osm.pbf ``` -------------------------------- ### Invert Tag Matching to Exclude Objects Source: https://osmcode.org/osmium-tool/manual.html Excludes objects tagged with 'building'. Use the `-i` or `--invert-match` option to select everything *except* objects matching the filter. Useful when you know what you don't want. ```bash osmium tags-filter -i city.osm.pbf wr/building \ -o no-buildings.osm.pbf ``` -------------------------------- ### Check if OSM File is Sorted Source: https://osmcode.org/osmium-tool/manual.html Uses `osmium fileinfo` to check if an OSM file has its objects ordered by type and ID. Look for the 'Objects ordered' line in the output. ```bash > osmium fileinfo -e input.osm.pbf ... Objects ordered (by type and id): yes ... ``` -------------------------------- ### Filter History Data by Specific Point in Time Source: https://osmcode.org/osmium-tool/manual.html Takes a filtered history file and extracts data for a specific date and time, outputting it to a new OSM file. ```bash osmium time-filter filtered.osh.pbf 2018-03-01T00:00:00Z -o result.osm.pbf ``` -------------------------------- ### Create Geographic Extract by Polygon File Source: https://osmcode.org/osmium-tool/manual.html Extracts OSM data within a polygon defined in a GeoJSON or POLY file. ```bash osmium extract -p paris-polygon.geojson france.pbf -o paris.pbf ``` ```bash osmium extract -p paris-polygon.poly france.pbf -o paris.pbf ``` -------------------------------- ### Filter by Tag Value Substring (Case-Sensitive) Source: https://osmcode.org/osmium-tool/manual.html Finds nodes or ways where the 'name' tag contains the substring 'school' (case-sensitive). For case-insensitive matching, both cases may need to be specified. ```bash nw/name=*school ``` ```bash nw/name=*School ``` -------------------------------- ### Overwrite existing output file Source: https://osmcode.org/osmium-tool/manual.html Disables the default safety check that prevents overwriting existing files using the `-O` or `--overwrite` option. Use with caution to avoid accidental data loss. ```bash osmium cat --overwrite input.osm.pbf -o output.osm.bz2 ``` -------------------------------- ### Filter History File by Time Source: https://osmcode.org/osmium-tool/manual.html Use `osmium time-filter` to extract all objects visible at a specific point in time from a history file. The output is a standard OSM data file. ```bash osmium time-filter history.osm.pbf 2015-01-01T00:00:00Z -o 2015.osm.pbf ``` -------------------------------- ### Filter Ways by Multiple Highway Values Source: https://osmcode.org/osmium-tool/manual.html Selects ways tagged with any of the specified highway types: 'motorway', 'trunk', or 'primary'. Useful for filtering major roads. ```bash w/highway=motorway,trunk,primary ``` -------------------------------- ### Exclude Relations by Tag Value Source: https://osmcode.org/osmium-tool/manual.html Finds all relations that do not have the 'type' tag set to 'multipolygon' or 'route'. Useful for excluding specific relation types. ```bash r/type!=multipolygon,route ``` -------------------------------- ### Filter Ways with Specific 'highway' Value Source: https://osmcode.org/osmium-tool/manual.html Extracts ways tagged with a specific highway type, such as 'primary'. Useful for targeting particular road classifications. ```bash osmium tags-filter rome.osm.pbf w/highway=primary \ -o highways-in-rome.osm.pbf ``` -------------------------------- ### Extract Relation and its Members for Polygon Source: https://osmcode.org/osmium-tool/manual.html Extracts a specific relation and its referenced members (nodes, ways) from an OSM file, stripping tags from non-relation objects. ```bash osmium getid -r -t france.pbf r7444 -o paris-boundary.osm ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.