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