This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

Merging different tag filtering with Osmosis

0

I'm trying to filter sport, leisure and amenity keys and then merge them with Osmosis:

osmosis --read-pbf file=switzerland.pbf --tf accept-nodes sport=* --tf accept-ways sport=* --tf reject-relations outPipe.0="sport" --read-pbf file=switzerland.pbf --tf accept-nodes amenity=* --tf accept-ways amenity=* --tf reject-relations outPipe.0="amenity" --read-pbf file=switzerland.pbf --tf accept-nodes leisure=* --tf accept-ways leisure=* --tf reject-relations outPipe.0="leisure" --merge inPipe.0="sport" inPipe.1="amenity" inPipe.2="leisure" --write-pgsql host=128.178.1.1 database=myDB user=myUsn password=myPwd

I have this error message that I don't understand:

The following named pipes (leisure) and 0 default pipes have not been terminated with appropriate output sinks.

I'm new with Osmosis. Sorry if this is a stupid question. But I cannot find the error.

Thank you in advance.

asked 14 Apr '14, 10:35

antonind's gravatar image

antonind
41449
accept rate: 0%

edited 14 Apr '14, 10:38


2 Answers:

1

--merge can only merge two pipes, not more; you must use two instances of --merge to merge three pipes. Try this:

osmosis \
  --read-pbf switzerland.osm.pbf --tf accept-nodes sport=* --tf accept-ways sport=* --tf reject-relations \
 --read-pbf file=switzerland.osm.pbf --tf accept-nodes amenity=* --tf accept-ways amenity=* --tf reject-relations \
 --read-pbf file=switzerland.osm.pbf --tf accept-nodes leisure=* --tf accept-ways leisure=* --tf reject-relations  \
 --merge --merge --write-pgsql host=128.178.1.1 database=myDB user=myUsn password=myPwd

You might want to give osmfilter a try, it is less complicated for use cases like this.

answered 14 Apr '14, 11:17

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

edited 14 Apr '14, 11:29

SomeoneElse's gravatar image

SomeoneElse ♦
36.9k71370866

0

Your error message is explained in another answer (the merge task can merge only two pipes, so you need two merge tasks). But there's another way to address your problem, which is to avoid merging entirely: You're filtering one tag pattern in each of three parallel pipelines, then merging those pipelines. In fact, each tag-filter task can accept more than one tag pattern, and will accept/reject entities if they match any of those supplied tag patterns. Here is an alternative command creating a single pipeline that should produce exactly the same results as your three-pipeline approach:

osmosis \
 --read-pbf switzerland.osm.pbf \
 --tf accept-nodes sport=* amenity=* leisure=* \
 --tf accept-ways sport=* amenity=* leisure=* \
 --tf reject-relations \
 --write-pgsql host=128.178.1.1 database=myDB user=myUsn password=myPwd

However, both your command and the one I proposed will probably not produce the output you are expecting. Both commands are retaining all nodes and ways that have a sport, amenity, or leisure tag, but they are not retaining any nodes referenced by these ways if the referenced nodes don't also have a sport, amenity, or leisure tag. This is the purpose of the used-node task: it will retain any nodes that are referenced by a retained way.

We can't just insert a used-node task into this single pipeline, because we want to retain both the nodes with certain tags and the nodes used by ways with those tags. So here you need two pipelines, but only one merge task:

osmosis \
 --read-pbf switzerland.osm.pbf \
 --tf accept-nodes sport=* amenity=* leisure=* \
 --tf reject-ways \
 --tf reject-relations \
 --read-pbf switzerland.osm.pbf \
 --tf accept-ways sport=* amenity=* leisure=* \
 --tf reject-relations \
 --used-node \
 --merge \
 --write-pgsql host=128.178.1.1 database=myDB user=myUsn password=myPwd

answered 06 Feb '16, 18:43

abyrd's gravatar image

abyrd
111
accept rate: 0%