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

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


You need a recurse filter:

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

Here's a demo.

permanent link

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

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:

×236
×5

question asked: 14 Jan '19, 19:55

question was seen: 1,753 times

last updated: 15 Jan '19, 09:44

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