Scroll to navigation

OSMIUM-TAGS-FILTER(1) OSMIUM-TAGS-FILTER(1)

NAME

osmium-tags-filter - filter objects matching specified keys/tags

SYNOPSIS

osmium tags-filter [OPTIONS] OSM-FILE FILTER-EXPRESSION...

osmium tags-filter [OPTIONS] --expressions=FILE OSM-FILE

DESCRIPTION

Get objects matching the specified expressions from the input and write them to the output. Expressions can either be specified on the command line or in an expressions file. See the FILTER EXPRESSIONS section for a description of the filter expression format.

All objects matching the expressions will be read from OSM-FILE and written to the output. All objects referenced from those objects will also be added to the output unless the option -R, --omit-referenced is used. This applies to nodes referenced in ways and members referenced in relations.

If the option -R, --omit-referenced is used, the input file is read only once, otherwise the input file will possibly be read up to three times.

Objects will be written out in the order they are found in the OSM-FILE.

The command will only work correctly on history files if the -R/--omit-referenced option is used.

OPTIONS

Read expressions from the specified file, one per line. Empty lines are ignored. Everything after the comment character (#) is also ignored. The the FILTER EXPRESSIONS section for further details.
Invert the sense of matching. Exclude all objects with matching tags.
Omit the nodes referenced from matching ways and members referenced from matching relations.

COMMON OPTIONS

Show usage help.
Set verbose mode. The program will output information about what it is doing to stderr.
Show progress bar. Usually a progress bar is only displayed if STDERR is detected to be a TTY. With this option a progress bar is always shown. Note that a progress bar will never be shown when reading from STDIN or a pipe.
Do not show progress bar. Usually a progress bar is displayed if STDERR is detected to be a TTY. With this option the progress bar is suppressed. Note that a progress bar will never be shown when reading from STDIN or a pipe.

INPUT OPTIONS

The format of the input file(s). Can be used to set the input format if it can't be autodetected from the file name(s). This will set the format for all input files, there is no way to set the format for some input files only. See osmium-file-formats(5) or the libosmium manual for details.

OUTPUT OPTIONS

The format of the output file. Can be used to set the output file format if it can't be autodetected from the output file name. See osmium-file-formats(5) or the libosmium manual for details.
Call fsync after writing the output file to force flushing buffers to disk.
The name and version of the program generating the output file. It will be added to the header of the output file. Default is "osmium/" and the version of osmium.
Name of the output file. Default is '-' (STDOUT).
Allow an existing output file to be overwritten. Normally osmium will refuse to write over an existing file.
Add output header option. This option can be given several times. See the libosmium manual for a list of allowed header options.

FILTER EXPRESSIONS

A filter expression specifies a tag or tags that should be found in the data and the type of object (node, way, or relation) that should be matched.

The object type(s) comes first, then a slash (/) and then the rest of the expression. Object types are specified as 'n' (for nodes), 'w' (for ways), and 'r' (for relations). Any combination of them can be used. If the object type is not specified, the expression matches all object types.

Some examples:

Matches all nodes with the key "amenity".
Matches all nodes or ways with the key "highway".
/note
Matches objects of any type with the key "note".
Matches objects of any type with the key "note".
Matches all ways with the key "highway" and value "primary".
Matches all ways with the key "highway" and a value other than "primary".
Matches all relations with key "type" and value "multipolygon" or "boundary".
Matches any way with a "name" or "name:de" tag with the value "Kastanienallee" or "Kastanienstrasse".
Matches all nodes with any key starting with "addr:"
Matches all nodes with a name that contains the word "Paris".

If there is no equal sign ("=") in the expression only keys are matched and values can by anything. If there is an equal sign ("=") in the expression, the key is to the left and the value to the right. An exclamation sign ("!") before the equal sign means: A tag with that key, but not the value(s) to the right of the equal sign. A leading or trailing asterisk ("*") can be used for substring or prefix matching, respectively. Commas (",") can be used to separate several keys or values.

All filter expressions are case-sensitive. There is no way to escape the special characters such as "=", "*" and ",". You can not mix comma-expressions and "*"-expressions.

The filter expressions specified in a file and/or on the command line are matched in the order they are given. To achieve best performance, put expressions expected to match more often first.

DIAGNOSTICS

osmium tags-filter exits with exit code

0
if everything went alright,
1
if there was an error processing the data, or
2
if there was a problem with the command line arguments.

MEMORY USAGE

osmium tags-filter does all its work on the fly and only keeps tables of object IDs it needs in main memory. If the -R/--omit-referenced option is used, no IDs are kept in memory.

EXAMPLES

Get all amenity nodes from the Berlin PBF file:

osmium tags-filter -o amenties.osm.pbf berlin.osm.pbf n/amenity

Get all objects (nodes, ways, or relations) with a note tag:

osmium tags-filter -R -o notes.osm.pbf berlin.osm.pbf note

Get all nodes and ways with a highway tag and all relations tagged with type=restriction plus all referenced objects:

osmium tags-filter -o filtered.osm.pbf planet.osm.pbf \
    nw/highway r/type=restriction

SEE ALSO

osmium(1), osmium-file-formats(5)
Osmium website (http://osmcode.org/osmium-tool/)

COPYRIGHT

Copyright (C) 2013-2017 Jochen Topf <jochen@topf.org>.

License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

CONTACT

If you have any questions or want to report a bug, please go to http://osmcode.org/contact.html

AUTHORS

Jochen Topf <jochen@topf.org>.

1.6.1