1

I want to extract the different points of interest from OpenStreetMap. Some of them are represented as ways (e.g., a large sport center might be represented as the building, i.e., as a way), others are represented as nodes. I am using Osmosis to export these elements from the Swiss version of OpenStreetMap. I'm trying to filter sport, leisure and amenity keys and then merge them:

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

It is based on the description of tag-filtering on Osmosis detailed usage page.

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 and I cannot find the error.

5

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
2

Frederik Ramm answered on help.openstreetmap.org (edited by SomeoneElse):

--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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.