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

How to download a relation with the tidy elements?

1

I am trying to download a bus route. I want to obtain the elements that compose this relation of a tidy way, as they appear originally in the relation.

alt text

https://www.openstreetmap.org/api/0.6/relation/3723432

But when I download the route in the osm resulting file the ways are not ordered. This complicates the analysis that I want to realize in a Geographic Information System (I need to extract the nodes that the route form of a correlative way, from beginning to end).

https://www.openstreetmap.org/api/0.6/relation/3723432/full

Is there any mode to get the real order of the ways of a route? Also it serves me in the worst case some way to identify the position of each arc.

asked 08 May '14, 12:29

egofer's gravatar image

egofer
26112
accept rate: 0%


One Answer:

4

The file that you get when downloading the relation contains one relation element, several way elements, and several node elements. The relation element will contain references to the ways, in the right order - like

<member type="way" ref="123" />
<member type="way" ref="555" />

and so on. You will then have to extract the way elements from the file in this order, and the ways will in turn reference the nodes which again, you have to extract in the order given in the way.

This is something that will require just a few lines of code in a programming language of your choice. OSM itself doesn't provide a service that does this job for you. But you might want to check out the answers to "Export a way as GPX".

answered 11 May '14, 12:26

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Source code available on GitHub .