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

How to get coordinates and names of public transport stations of a specific route?

0

I am attempting to use the Overpass API to retrieve data about a public transport route: the list of bus stops, their names and coordinates (ideally, in CSV format).

This query shows me all the stations in the selected area, which is not specific enough:

[out:json][timeout:25];
// gather results
(
  // query part for: “public_transport=stop_position”
  node["public_transport"="stop_position"]({{bbox}});
  way["public_transport"="stop_position"]({{bbox}});
  relation["public_transport"="stop_position"]({{bbox}});
);
out body;
>;
out skel qt;

I know that the relation I need is 8649765, so ideally I would just run a query that says show me all nodes that match "public_transport"="stop_position" and for which the relation is 8649765. However, I did not find any examples that explicitly provide a relation ID.

The reason I think this approach is necessary is because the route in question covers several cities, so I want the query not to be tied to the location, but to the... well... relation.

How can this be accomplished?

asked 18 Feb '19, 14:42

ralien's gravatar image

ralien
16224
accept rate: 0%


One Answer:

2
relation (8649765);
>>;
node._ [public_transport=stop_position];
out;

answered 18 Feb '19, 22:17

andrewblack's gravatar image

andrewblack
3651214
accept rate: 57%

1

Thank you, this works, though I had to replace stop_position with platform to get the names of the stations too.

(19 Feb '19, 12:44) ralien

Glad it pointed in right direction. I will modify to put out a CSV

(20 Feb '19, 08:09) andrewblack

Source code available on GitHub .