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