NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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%


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

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
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×483
×181
×62

question asked: 18 Feb '19, 14:42

question was seen: 2,645 times

last updated: 20 Feb '19, 08:09

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum