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

How to extract only roads that are a part of a relation?

0

I want to retrieve a map of all the roads that are a part of a particular relation. This can be a specific public transport route in a city, or its entire public transport network. I have the following input data:

  • the map of the country downloaded from Geofabrik as country-latest.osm.pbf
  • the relation ID

For example, for the country of Moldova, relation 6726484 includes all the public transport routes in its capital.

Is it possible to filter this data with osmosis, using the command line?

So far my best shot at it is osmosis --rbf moldova-latest.osm.pbf --tf accept-ways highway=* --tf reject-ways highway=steps,footway,pedestrian,service,residential --wx moldova-roads-only.osm

In other words, I am removing all the ways that are not likely to be part of any route, but this is a very rough approach, and I suspect that I could get much better results if I could leverage the information about the relation itself.

How can this be accomplished?

asked 25 Jan '20, 16:57

ralien's gravatar image

ralien
16224
accept rate: 0%

edited 25 Jan '20, 20:53


One Answer:

1

You can do this with Osmium using the getid command:

osmium getid -r moldova-latest.osm.pbf rRELATION_ID

Osmium also has the tags-filter command to filter by tags if you need that, too.

answered 25 Jan '20, 20:13

Jochen%20Topf's gravatar image

Jochen Topf
5.2k55074
accept rate: 31%

edited 25 Jan '20, 20:14

Thanks, this does exactly what I wanted. I am marking it as the accepted answer, even though it is osmium rather than osmosis. I will edit the question title, to make it easier to find.

(25 Jan '20, 20:52) ralien

Source code available on GitHub .