OSMFILTER(1) | General Commands Manual | OSMFILTER(1) |
osmfilter - The experimental OSM filters data
osmfilter options [input file]
THIS PROGRAM IS FOR EXPERIMENTAL USE ONLY. PLEASE EXPECT MALFUNCTION AND DATA LOSS. SAVE YOUR DATA BEFORE STARTING THIS PROGRAM.
This program filters OpenStreetMap data.
The input file name must be supplied as command line argument. The file must not be a stream. Redirections from standard input will not work because the program needs random access to the file. You do not need to specify the input format, osmfilter will recognize these formats: .osm (XML), .osc (OSM Change File), .osh (OSM Full History), .o5m (speed-optimized) and .o5c (speed-optimized Change File).
The output format is .osm by default. If you want a different format, please specify it using the appropriate command line parameter.
--keep=OBJECT_FILTER
--keep-nodes=OBJECT_FILTER
--keep-ways=OBJECT_FILTER
--keep-relations=OBJECT_FILTER
--keep-nodes-ways=OBJECT_FILTER
--keep-nodes-relations=OBJECT_FILTER
--keep-ways-relations=OBJECT_FILTER
--drop=OBJECT_FILTER
--drop-nodes=OBJECT_FILTER
--drop-ways=OBJECT_FILTER
--drop-relations=OBJECT_FILTER
--drop-nodes-ways=OBJECT_FILTER
--drop-nodes-relations=OBJECT_FILTER
--drop-ways-relations=OBJECT_FILTER
--keep-tags=TAG_FILTER
--keep-node-tags=TAG_FILTER
--keep-way-tags=TAG_FILTER
--keep-relation-tags=TAG_FILTER
--keep-node-way-tags=TAG_FILTER
--keep-node-relation-tags=TAG_FILTER
--keep-way-relation-tags=TAG_FILTER
--drop-tags=TAG_FILTER
--drop-node-tags=TAG_FILTER
--drop-way-tags=TAG_FILTER
--drop-relation-tags=TAG_FILTER
--drop-node-way-tags=TAG_FILTER
--drop-node-relation-tags=TAG_FILTER
--drop-way-relation-tags=TAG_FILTER
--modify-tags=TAG_MODIFICATION_LIST
--modify-node-tags=TAG_MODIFICATION_LIST
--modify-way-tags=TAG_MODIFICATION_LIST
--modify-relation-tags=TAG_MODIFICATION_LIST
--modify-node-way-tags=TAG_MODIFICATION_LIST
--modify-node-relation-tags=TAG_MODIFICATION_LIST
--modify-way-relation-tags=TAG_MODIFICATION_LIST
--drop-author
--drop-version
--drop-nodes
--drop-ways
--drop-relations
--emulate-osmosis
--emulate-pbf2osm
--fake-author
--fake-version
--fake-lonlat
-h
--help
--ignore-dependencies
--out-key=KEYNAME
--out-count=KEYNAME
--out-osm
--out-osc
--out-osh
--out-o5m
--out-o5c
-o=<outfile>
-t=<tempfile>
--parameter-file=FILE
-v --verbose
Some of the command line arguments need a filter to be specified.
This filter definition consists of key/val pairs and uses the following
syntax:
"KEY1=VAL1 OP KEY2=VAL2 OP KEY3=VAL3 ..."
The tag filter determines which tags will be kept and which will
be not. For example :
--keep-tags="highway=motorway =primary"
will not accept "highway" tags other than "motorway" or
"primary". Note that neither the object itself will be deleted,
nor the remaining tags. If you want to drop every tag which is not mentioned
in a list, use this example:
all highway= amenity= name=
The tag modification list determines which tags will be modified.
The example
--modify-tags="highway=primary to =secondary"
will change every "primary" highway into "secondary". You
can also use comparisons or add additional tags:
--modify-way-tags="maxspeed>200 add highspeed=yes"
To speed-up the process, the program uses some main memory for a
hash table. By default, it uses 1200 MB for storing a flag for every
possible node, 150 for the way flags, and 10 relation flags. Every byte
holds the flags for 8 ID numbers, i.e., in 1200 MB the program can store
9600 million flags. As there are less than 5700 million IDs for nodes at
present (May 2018), 720 MB would suffice. So, for example, you can decrease
the hash sizes to e.g. 720, 80 and 2 MB (for relations, 2 flags are needed
each) using this option:
--hash-memory=720-80-2
But keep in mind that the OSM database is continuously expanding.
For this reason the program-own default value is higher than shown in the
example, and it may be appropriate to increase it in the future. If you do
not want to bother with the details, you can enter the amount of memory as a
sum, and the program will divide it by itself. For example:
--hash-memory=1000
These 1000 MiB will be split in three parts: 800 for nodes, 150 for ways, and 50 for relations.
Because we are taking hashes, it is not necessary to provide all the suggested memory; the program will operate with less hash memory too. But, in this case, the border filter will be less effective, i.e., some ways and some relations will be left in the output file although they should have been excluded. The maximum value the program accepts for the hash size is 4000 MiB; If you exceed the maximum amount of memory available on your system, the program will try to reduce this amount and display a warning message.
When filtering whole OSM objects (--keep...=, --drop...=), the input file must contain the objects ordered by their type: first, all nodes nodes, next, all ways, followed by all relations.
Usual .osm, .osc, .o5m and o5c files adhere to this condition. This means that you do not have to worry about this limitation. osmfilter will display an error message if this sequence is broken.
The number of key/val pairs in each filter parameter is limited to 1000, the length of each key or val is limited to 100.
This program is for experimental use. Expect malfunctions and data loss. Do not use the program in productive or commercial systems.
There is NO WARRANTY, to the extent permitted by law. Please send any bug reports to marqqs@gmx.eu
osmfilter europe.o5m --keep=amenity=bar -o=new.o5m
osmfilter a.osm --keep-nodes=lit=yes --drop-ways -o=light.osm
osmfilter a.osm --keep="place=city or ( place=town and
population>=10000 )" -o=b.osm
osmfilter region.o5m --keep="bridge=yes and layer>=2"
-o=r.o5m
osmfilter was written by Markus Weber
September 2013 |