1OSMIUM-TAGS-FILTER(1) OSMIUM-TAGS-FILTER(1)
2
3
4
6 osmium-tags-filter - filter objects matching specified keys/tags
7
9 osmium tags-filter [OPTIONS] OSM-FILE FILTER-EXPRESSION...
10 osmium tags-filter [OPTIONS] --expressions=FILE OSM-FILE
11
13 Get objects matching at least one of the specified expressions from the
14 input and write them to the output. Expressions can either be speci‐
15 fied on the command line or in an expressions file. See the FILTER EX‐
16 PRESSIONS section for a description of the filter expression format.
17
18 All objects matching the expressions will be read from OSM-FILE and
19 written to the output. All objects referenced from those objects will
20 also be added to the output unless the option --omit-referenced/-R is
21 used. This applies to nodes referenced in ways and members referenced
22 in relations.
23
24 If the option --omit-referenced/-R is used, the input file is read only
25 once, otherwise the input file will possibly be read up to three times.
26
27 Objects will be written out in the order they are found in the OSM-
28 FILE.
29
30 The command will only work correctly on history files if the --omit-
31 referenced/-R option is used. The command can not be used on change
32 files.
33
35 -e FILE, --expressions=FILE
36 Read expressions from the specified file, one per line. Empty
37 lines are ignored. Everything after the comment character (#)
38 is also ignored. See the FILTER EXPRESSIONS section for further
39 details.
40
41 -i, --invert-match
42 Invert the sense of matching. Exclude all objects with matching
43 tags.
44
45 -R, --omit-referenced
46 Omit the nodes referenced from matching ways and members refer‐
47 enced from matching relations.
48
49 -t, --remove-tags
50 Remove tags from objects that are not matching the filter ex‐
51 pression but are included to complete references (nodes in ways
52 and members of relations). If an object is both matching the
53 filter and used as a reference it will keep its tags.
54
56 -h, --help
57 Show usage help.
58
59 -v, --verbose
60 Set verbose mode. The program will output information about
61 what it is doing to STDERR.
62
63 --progress
64 Show progress bar. Usually a progress bar is only displayed if
65 STDOUT and STDERR are detected to be TTY. With this option a
66 progress bar is always shown. Note that a progress bar will
67 never be shown when reading from STDIN or a pipe.
68
69 --no-progress
70 Do not show progress bar. Usually a progress bar is displayed
71 if STDOUT and STDERR are detected to be a TTY. With this option
72 the progress bar is suppressed. Note that a progress bar will
73 never be shown when reading from STDIN or a pipe.
74
76 -F, --input-format=FORMAT
77 The format of the input file(s). Can be used to set the input
78 format if it can’t be autodetected from the file name(s). This
79 will set the format for all input files, there is no way to set
80 the format for some input files only. See osmium-file-for‐
81 mats(5) or the libosmium manual for details.
82
84 -f, --output-format=FORMAT
85 The format of the output file. Can be used to set the output
86 file format if it can’t be autodetected from the output file
87 name. See osmium-file-formats(5) or the libosmium manual for
88 details.
89
90 --fsync
91 Call fsync after writing the output file to force flushing buf‐
92 fers to disk.
93
94 --generator=NAME
95 The name and version of the program generating the output file.
96 It will be added to the header of the output file. Default is
97 “osmium/” and the version of osmium.
98
99 -o, --output=FILE
100 Name of the output file. Default is `-' (STDOUT).
101
102 -O, --overwrite
103 Allow an existing output file to be overwritten. Normally os‐
104 mium will refuse to write over an existing file.
105
106 --output-header=OPTION=VALUE
107 Add output header option. This command line option can be used
108 multiple times for different OPTIONs. See the osmium-output-
109 headers(5) man page for a list of available header options. For
110 some commands you can use the special format “OPTION!” (ie. an
111 exclamation mark after the OPTION and no value set) to set the
112 value to the same as in the input file.
113
115 A filter expression specifies a tag or tags that should be found in the
116 data and the type of object (node, way, or relation) that should be
117 matched.
118
119 The object type(s) comes first, then a slash (/) and then the rest of
120 the expression. Object types are specified as `n' (for nodes), `w'
121 (for ways), `r' (for relations), and `a' (for areas - closed ways with
122 4 or more nodes and relations with type=multipolygon or type=boundary
123 tag). Any combination of them can be used. If the object type is not
124 specified, the expression matches all object types.
125
126 Some examples:
127
128 n/amenity
129 Matches all nodes with the key “amenity”.
130
131 nw/highway
132 Matches all nodes or ways with the key “highway”.
133
134 /note Matches objects of any type with the key “note”.
135
136 note Matches objects of any type with the key “note”.
137
138 w/highway=primary
139 Matches all ways with the key “highway” and value “primary”.
140
141 w/highway!=primary
142 Matches all ways with the key “highway” and a value other than
143 “primary”.
144
145 r/type=multipolygon,boundary
146 Matches all relations with key “type” and value “multipolygon”
147 or “boundary”.
148
149 w/name,name:de=Kastanienallee,Kastanienstrasse
150 Matches any way with a “name” or “name:de” tag with the value
151 “Kastanienallee” or “Kastanienstrasse”.
152
153 n/addr:*
154 Matches all nodes with any key starting with “addr:”
155
156 n/name=*Paris
157 Matches all nodes with a name that contains the word “Paris”.
158
159 a/building
160 Matches any closed ways with 4 or more nodes or relations tagged
161 “building”. Relations must also have a tag “type=multipolygon”
162 or “type=boundary”.
163
164 If there is no equal sign (“=”) in the expression only keys are matched
165 and values can be anything. If there is an equal sign (“=”) in the ex‐
166 pression, the key is to the left and the value to the right. An excla‐
167 mation sign (“!”) before the equal sign means: A tag with that key, but
168 not the value(s) to the right of the equal sign. A leading or trailing
169 asterisk (“*”) can be used for substring or prefix matching, respec‐
170 tively. Commas (“,”) can be used to separate several keys or values.
171
172 All filter expressions are case-sensitive. There is no way to escape
173 the special characters such as “=”, “*” and “,”. You can not mix
174 comma-expressions and “*”-expressions.
175
176 The filter expressions specified in a file and/or on the command line
177 are matched in the order they are given. To achieve best performance,
178 put expressions expected to match more often first.
179
180 Area matches (with leading “a/”) do not check whether the matched ob‐
181 ject is a valid (multi)polygon, they only check whether an object might
182 possibly be turned into a (multi)polygon. This is the case for all
183 closed ways (where the first and last node are the same) with 4 or more
184 nodes and for all relations that have an additional “type=multipolygon”
185 or “type=boundary” tag.
186
188 osmium tags-filter exits with exit code
189
190 0 if everything went alright,
191
192 1 if there was an error processing the data, or
193
194 2 if there was a problem with the command line arguments.
195
197 osmium tags-filter does all its work on the fly and only keeps tables
198 of object IDs it needs in main memory. If the --omit-referenced/-R op‐
199 tion is used, no IDs are kept in memory.
200
202 Get all amenity nodes from the Berlin PBF file:
203
204 osmium tags-filter -o amenties.osm.pbf berlin.osm.pbf n/amenity
205
206 Get all objects (nodes, ways, or relations) with a note tag:
207
208 osmium tags-filter -R -o notes.osm.pbf berlin.osm.pbf note
209
210 Get all nodes and ways with a highway tag and all relations tagged with
211 type=restriction plus all referenced objects:
212
213 osmium tags-filter -o filtered.osm.pbf planet.osm.pbf \
214 nw/highway r/type=restriction
215
217 • osmium(1), osmium-file-formats(5), osmium-output-headers(5)
218
219 • Osmium website (https://osmcode.org/osmium-tool/)
220
222 Copyright (C) 2013-2022 Jochen Topf <jochen@topf.org>.
223
224 License GPLv3+: GNU GPL version 3 or later <https://gnu.org/li‐
225 censes/gpl.html>. This is free software: you are free to change and
226 redistribute it. There is NO WARRANTY, to the extent permitted by law.
227
229 If you have any questions or want to report a bug, please go to
230 https://osmcode.org/contact.html
231
233 Jochen Topf <jochen@topf.org>.
234
235
236
237 1.14.0 OSMIUM-TAGS-FILTER(1)