1OSMFILTER(1)                General Commands Manual               OSMFILTER(1)
2
3
4

NAME

6       osmfilter - The experimental OSM filters data
7

SYNOPSIS

9       osmfilter options [input file]
10

DESCRIPTION

12       THIS  PROGRAM  IS FOR EXPERIMENTAL USE ONLY.  PLEASE EXPECT MALFUNCTION
13       AND DATA LOSS.  SAVE YOUR DATA BEFORE STARTING THIS PROGRAM.
14
15       This program filters OpenStreetMap data.
16
17       The input file name must be supplied as command line argument. The file
18       must  not  be  a stream. Redirections from standard input will not work
19       because the program needs random access to the file. You do not need to
20       specify  the input format, osmfilter will recognize these formats: .osm
21       (XML),  .osc  (OSM  Change  File),  .osh  (OSM  Full   History),   .o5m
22       (speed-optimized) and .o5c (speed-optimized Change File).
23
24       The  output  format is .osm by default. If you want a different format,
25       please specify it using the appropriate command line parameter.
26

OPTIONS

28       --keep=OBJECT_FILTER
29
30              All object types (nodes, ways and relations)  will  be  kept  if
31              they  meet  the  filter  criteria.  Same  applies  to  dependent
32              objects, e.g. nodes in ways, ways  in  relations,  relations  in
33              other  relations.  Please look below for a syntax description of
34              OBJECT_FILTER.
35
36       --keep-nodes=OBJECT_FILTER
37       --keep-ways=OBJECT_FILTER
38       --keep-relations=OBJECT_FILTER
39       --keep-nodes-ways=OBJECT_FILTER
40       --keep-nodes-relations=OBJECT_FILTER
41       --keep-ways-relations=OBJECT_FILTER
42
43              Same as above, but just for the specified object types.
44
45       --drop=OBJECT_FILTER
46
47              All object types (nodes, ways and relations) which meet the sup‐
48              plied filter criteria will be dropped, regardless of meeting the
49              criteria of a keep filter (see above).  Please look below for  a
50              syntax description of OBJECT_FILTER.
51
52       --drop-nodes=OBJECT_FILTER
53       --drop-ways=OBJECT_FILTER
54       --drop-relations=OBJECT_FILTER
55       --drop-nodes-ways=OBJECT_FILTER
56       --drop-nodes-relations=OBJECT_FILTER
57       --drop-ways-relations=OBJECT_FILTER
58
59              Same as above, but just for the specified object types.
60
61       --keep-tags=TAG_FILTER
62
63              The  in  TAG_FILTER  specified  tags  will be allowed on output.
64              Please look below for a syntax description of TAG_FILTER.
65
66       --keep-node-tags=TAG_FILTER
67       --keep-way-tags=TAG_FILTER
68       --keep-relation-tags=TAG_FILTER
69       --keep-node-way-tags=TAG_FILTER
70       --keep-node-relation-tags=TAG_FILTER
71       --keep-way-relation-tags=TAG_FILTER
72
73              Same as above, but just for the specified object types.
74
75       --drop-tags=TAG_FILTER
76
77              The specified tags will be dropped. This  overrules  the  previ‐
78              ously  described parameter --keep-tags.  Please look below for a
79              syntax description of TAG_FILTER.
80
81       --drop-node-tags=TAG_FILTER
82       --drop-way-tags=TAG_FILTER
83       --drop-relation-tags=TAG_FILTER
84       --drop-node-way-tags=TAG_FILTER
85       --drop-node-relation-tags=TAG_FILTER
86       --drop-way-relation-tags=TAG_FILTER
87
88              Same as above, but just for the specified object types.
89
90       --modify-tags=TAG_MODIFICATION_LIST
91
92              The specified tags will be modified. This is done after any fil‐
93              tering  (see  --keep, --keep-tags, --drop, --drop-tags).  Please
94              look below for a description of TAG_MODIFICATION_LIST.
95
96       --modify-node-tags=TAG_MODIFICATION_LIST
97       --modify-way-tags=TAG_MODIFICATION_LIST
98       --modify-relation-tags=TAG_MODIFICATION_LIST
99       --modify-node-way-tags=TAG_MODIFICATION_LIST
100       --modify-node-relation-tags=TAG_MODIFICATION_LIST
101       --modify-way-relation-tags=TAG_MODIFICATION_LIST
102
103              Same as above, but just for the specified object types.
104
105       --drop-author
106
107              For most applications the author tags are  not  needed.  If  you
108              specify  this  option, no author information will be written: no
109              changeset, user or timestamp.
110
111       --drop-version
112
113              If you want to exclude not only the author information but  also
114              the version number, specify this option.
115
116       --drop-nodes
117       --drop-ways
118       --drop-relations
119
120              According  to the combination of these parameters, no members of
121              the referred section will be written.
122
123       --emulate-osmosis
124       --emulate-pbf2osm
125
126              In case of .osm output format, the program will try to  use  the
127              same data syntax as Osmosis, resp. pbf2osm.
128
129       --fake-author
130
131              If you have dropped author information (--drop-author) that data
132              will be lost, of course. Some programs  however  require  author
133              information  on  input  although they do not need that data. For
134              this purpose, you can fake  the  author  information.   o5mfiler
135              will write changeset 1, timestamp 1970.
136
137       --fake-version
138
139              Same  as --fake-author, but - if .osm xml is used as output for‐
140              mat - only the version number will be written (version 1).  This
141              is useful if you want to inspect the data with JOSM.
142
143       --fake-lonlat
144
145              Some  programs depend on getting longitude/latitude values, even
146              when the object in question shall be deleted. With  this  option
147              you can have osmfilter to fake these values:
148              ... lat="0" lon="0" ...
149              Note that this is for XML files only (.osc and .osh).
150
151       -h
152
153              Display a short parameter overview.
154
155       --help
156
157              Display this help.
158
159       --ignore-dependencies
160
161              Usually, all member nodes of a way which meets the filter crite‐
162              ria will be  included  as  well.  Same  applies  to  members  of
163              included  relations.  If  you  activate  this  option, all these
164              dependencies between OSM objects will be ignored.
165
166       --out-key=KEYNAME
167
168              The output will contain no regular OSM data but only statistics:
169              a list of all used keys is assembled. Left to each key, the num‐
170              ber of occurrences is printed.  If KEYNAME is given, the program
171              will  list  all  values  which are used in connections with this
172              key.  You may use wildcard characters for KEYNAME, but  only  at
173              the beginning and/or at the end. For example:  --out-key=addr:*
174
175       --out-count=KEYNAME
176
177              Same  as  --out-key=,  but  the  list is sorted by the number of
178              occurrences of the keys resp. values.
179
180       --out-osm
181
182              Data will be written in .osm format. This is the default  output
183              format.
184
185       --out-osc
186
187              The  OSM Change format will be used for output. Please note that
188              OSM objects which are to be deleted are represented by their ids
189              only.
190
191       --out-osh
192
193              For  every  OSM  object,  the  appropriate 'visible' tag will be
194              added to meet 'full planet history' specification.
195
196       --out-o5m
197
198              The .o5m format will be used. This format has the same structure
199              as  the  conventional  .osm  format,  but the data are stored as
200              binary numbers and are therefore much more compact than in  .osm
201              format.  No  packing  is  used, so you can pack .o5m files using
202              every file packer you want, e.g. lzo, bz2, etc.
203
204       --out-o5c
205
206              This is the change file format of .o5m data format. All <delete>
207              tags  will not be performed as delete actions but converted into
208              .o5c data format.
209
210       -o=<outfile>
211
212              Standard output will be rerouted to the specified file.   If  no
213              output  format  has  been  specified,  the  program will proceed
214              according to the file name extension.
215
216       -t=<tempfile>
217
218              osmfilter uses  a  temporary  file  to  process  interrelational
219              dependencies.  This  parameter  defines  the  name  prefix.  The
220              default value is "osmfilter_tempfile".
221
222       --parameter-file=FILE
223
224              If you want to supply one ore more command line arguments  by  a
225              parameter  file,  please  use  this  option and specify the file
226              name. Within the parameter file, parameters must be separated by
227              empty  lines. Line feeds inside a parameter will be converted to
228              spaces.  Lines starting with "// " will be treated as comments.
229
230       -v --verbose
231
232              With activated 'verbose' mode, some statistical data and diagno‐
233              sis  data will be displayed.  If -v resp. --verbose is the first
234              parameter in the line, osmfilter will display all input  parame‐
235              ters.
236
237   OBJECT_FILTER
238       Some  of the command line arguments need a filter to be specified. This
239       filter definition consists of key/val pairs and uses the following syn‐
240       tax:
241       "KEY1=VAL1 OP KEY2=VAL2 OP KEY3=VAL3 ..."
242
243              OP is the Boolean operator, it must be either "and" or "or".  As
244              usual, "and" will be processed prior to "or".  If  you  want  to
245              influence the sequence of processing, you may use brackets to do
246              so. Please note that brackets always must be padded  by  spaces.
247              Example:  lit=yes and ( note=a or source=b ) Instead of each "="
248              you may enter one of these comparison operators: != (not equal),
249              <,  >,  <=,  >= The program will use ASCII-alphabetic comparison
250              unless you compare against a value  which  is  starting  with  a
251              digit.  If there are different possible values for the same key,
252              you need to write the key only once. For example:
253              "amenity=restaurant =pub =bar"
254
255              It is allowed to omit the value. In this case, the program  will
256              accept every value for the defined key. For example:
257              "highway= and lit=yes"
258
259              You  may  use  wildcard characters for key or value, but only at
260              the beginning and/or at the end. For example:
261              "wikipedia:*=highway=*ary  ref_name=*central*"
262
263              Please be careful with wildcards in keys since  only  the  first
264              key  which meets the pattern will be processed.  There are three
265              special keys which represent object id, user id and  user  name:
266              @id,  @uid  and  @user.  They  allow  you  to search for certain
267              objects or for edits of specific users.
268
269   TAG_FILTER
270       The tag filter determines which tags will be kept  and  which  will  be
271       not. For example :
272       --keep-tags="highway=motorway =primary"
273       will not accept "highway" tags other than "motorway" or "primary". Note
274       that neither the object itself will be deleted, nor the remaining tags.
275       If  you  want  to  drop every tag which is not mentioned in a list, use
276       this example:
277       all highway= amenity= name=
278
279   TAG_MODIFICATION_LIST
280       The tag modification list determines which tags will be  modified.  The
281       example
282       --modify-tags="highway=primary to =secondary"
283       will change every "primary" highway into "secondary".  You can also use
284       comparisons or add additional tags:
285       --modify-way-tags="maxspeed>200 add highspeed=yes"
286

TUNING

288       To speed-up the process, the program uses some main memory for  a  hash
289       table.  By default, it uses 1200 MB for storing a flag for every possi‐
290       ble node, 150 for the way flags, and 10  relation  flags.   Every  byte
291       holds  the  flags  for  8  ID numbers, i.e., in 1200 MB the program can
292       store 9600 million flags. As there are less than 5700 million  IDs  for
293       nodes  at  present  (May 2018), 720 MB would suffice.  So, for example,
294       you can decrease the hash sizes to e.g. 720, 80 and  2  MB  (for  rela‐
295       tions, 2 flags are needed each) using this option:
296       --hash-memory=720-80-2
297
298       But  keep  in mind that the OSM database is continuously expanding. For
299       this reason the program-own default value is higher than shown  in  the
300       example,  and  it  may be appropriate to increase it in the future.  If
301       you do not want to bother with the details, you can enter the amount of
302       memory  as  a sum, and the program will divide it by itself.  For exam‐
303       ple:
304       --hash-memory=1000
305
306       These 1000 MiB will be split in three parts: 800  for  nodes,  150  for
307       ways, and 50 for relations.
308
309       Because  we  are  taking hashes, it is not necessary to provide all the
310       suggested memory; the program will operate with less hash  memory  too.
311       But, in this case, the border filter will be less effective, i.e., some
312       ways and some relations will be left in the output file  although  they
313       should  have  been excluded.  The maximum value the program accepts for
314       the hash size is 4000 MiB; If you exceed the maximum amount  of  memory
315       available  on  your  system, the program will try to reduce this amount
316       and display a warning message.
317

LIMITATIONS

319       When filtering whole OSM objects (--keep...=,  --drop...=),  the  input
320       file  must  contain the objects ordered by their type: first, all nodes
321       nodes, next, all ways, followed by all relations.
322
323       Usual .osm, .osc, .o5m and o5c files adhere  to  this  condition.  This
324       means  that  you  do not have to worry about this limitation. osmfilter
325       will display an error message if this sequence is broken.
326
327       The number of key/val pairs in each  filter  parameter  is  limited  to
328       1000, the length of each key or val is limited to 100.
329

NOTES

331       This  program  is  for  experimental  use. Expect malfunctions and data
332       loss. Do not use the program in productive or commercial systems.
333
334       There is NO WARRANTY, to the extent permitted by law.  Please send  any
335       bug reports to marqqs@gmx.eu
336

EXAMPLE

338       osmfilter europe.o5m --keep=amenity=bar -o=new.o5m
339       osmfilter a.osm --keep-nodes=lit=yes --drop-ways -o=light.osm
340       osmfilter   a.osm   --keep="place=city  or  (  place=town  and  popula‐
341       tion>=10000 )" -o=b.osm
342       osmfilter region.o5m --keep="bridge=yes and layer>=2" -o=r.o5m
343

SEE ALSO

345       osmconvert(1), osmupdate(1)
346

AUTHORS

348       osmfilter was written by Markus Weber
349
350
351
352
353                                September 2013                    OSMFILTER(1)
Impressum