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

Overpass turbo: Finding capitals of relations

0

I'm looking for a way to grab the capital of a relation, for which I have the OSM ID.

I can print out the relation like this:

[out:json];
relation(8654);
out body;

and I have the data (node with "role": "admin_centre"), however I would then need to parse the JSON myself which is:

  • a waste of bandwidth for everyone involved.
  • needless processing on my side
  • I would then need to make another query to OSM to get data for the node

What I need is the data found here https://www.openstreetmap.org/node/26761400 , but in JSON format and through the API. I don't have the OSM ID of the node, only the relation.

So I would like to know if there is a way to get just the node data.

Thanks!

asked 14 Jan '19, 19:55

ianare's gravatar image

ianare
16112
accept rate: 0%

edited 14 Jan '19, 19:56


One Answer:

2

You need a recurse filter:

[out:json];
relation(8654);
node(r:"admin_centre");
out body;

Here's a demo.

answered 15 Jan '19, 01:37

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

Perfect, thank you! I had seen the recurse filter in the docs but did not understand it.

(15 Jan '19, 09:44) ianare

Source code available on GitHub .