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

Extract nodes from way

0

Hi, I have an 'way id' of my route. I want to extract all nodes which belongs to this specific route. I can make a query e.g.: http://api.openstreetmap.org/api/0.6/way/xxxyyzz In response I receive series of node reference id's. Then I need to make recursive lookup to search each single point to get GPS data. Do you know automatic tool to extract such data? I will provide way_id and in response get series of GPS coordinates. It is fair easy to write such tool but maybe you know readily available software.

asked 22 Dec '10, 18:24

razor85's gravatar image

razor85
6113
accept rate: 0%

edited 21 Jan '11, 09:25

TomH's gravatar image

TomH ♦♦
3.3k83943


2 Answers:

4

There is an API request that returns the way and all its nodes:

http://api.openstreetmap.org/api/0.6/way/xxxyyzz/full

answered 22 Dec '10, 18:38

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

1

You can download http://api.openstreetmap.org/api/0.6/way/xxxyyzz/full instead of http://api.openstreetmap.org/api/0.6/way/xxxyyzz/. This will contain all the nodes that are in this way, thus avoiding the need for further queries.

You can use something like

wget -q -O - http://api.openstreetmap.org/api/0.6/way/xxxyyzz/full | sed -ne 's/<node.*lat="\(.*\)" lon="\(.*\)" version.*/\1 \2/p'

to limit output to the latitude and longitude of the node. (And yes I know that parsing XML with regex is evil.)

answered 22 Dec '10, 18:41

petschge's gravatar image

petschge
8.3k217398
accept rate: 21%

Source code available on GitHub .