openstreetmaposmosis

How to filter out all amenities with osmfilter together with any other tag information they have?


I managed to download a planet file from OSM, and converted it to o5m format with osmconvert, and additional deleted all of the author information from it, to keep the file size smaller. I am trying to fetch every POI from this database from the whole world, so I am not interested in cities, towns, highways, ways, etc, only amenities.

First I tried to achieve this by using osmosis, which as it appears manages to do what I want, only it always runs out of memory, cause the file is too huge to process. (I could split the file up to smaller ones, but I would like to avoid this if possible).

I tried experimenting with osmfilter, there, I managed to filter out every node which has a tag named amenity in it, but I have several problems which I can't solve:

a. if I use the following command:

osmfilter planet.o5m -v --keep-tags="amenity=" -o=amenities.osm

It keeps all nodes, and filters out every tag which doesn't have amenity in it's name.

b. if I use this command:

osmfilter planet.o5m -v --keep-tags="all amenity=" -o=amenities.osm

It now filters out all nodes which doesn't have the amenity tag, but also filters out all additional tags from the matching nodes, which contain information that I need(for example, name of the POI, or description)

c. if I use this command:

osmfilter planet.o5m -v --keep-tags="all amenity= all name=" -o=amenities.osm

Filters out every node which has EITHER name or amenity in it's tags, which leaves me with several named cities or highways(data that I don't need).

I also tried separating this with an AND operator, but it says, that I can't use AND operator when filtering for tags. Any idea how could I achieve the desired result?

End note: I am running a Windows 7 system, so no Linux based program would help me:|


Solution

  • Please try --keep= option instead of --keep-tags option. The latter has no influence on which object will be kept in the file.

    For example:

    osmfilter planet.o5m --keep="amenity= and name=" -o=amenities.osm

    will keep just that objects which have an amenity tag AND a name tag.

    Be aware that all dependent objects will also be in the output file. For example, if there is a way object with the requested tags, each node of this way will be in the output file as well. The same is valid for relations and their dependent ways and nodes. If you do not want this kind of behaviour, please add --ignore-dependencies

    Some more information can be found here: https://wiki.openstreetmap.org/wiki/Osmfilter