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

Get relation id by node id (which is a member of the relation)

1
1

Hi everyone,

how can i get the relation id by the node id?

Or in other words - how can i get from here: https://www.openstreetmap.org/api/0.6/node/240076989 to here: https://www.openstreetmap.org/api/0.6/relation/191645 (which both is the city of dresden)

Thank you for every contribution.

asked 29 Nov '17, 12:53

T4Titan's gravatar image

T4Titan
26113
accept rate: 0%


2 Answers:

2

Just append /relations to your first link: https://www.openstreetmap.org/api/0.6/node/240076989/relations

This will return all relations the node is part of. This feature is described here.

answered 29 Nov '17, 12:56

scai's gravatar image

scai ♦
33.3k21309459
accept rate: 23%

Greetings to dresden :)

(29 Nov '17, 13:44) T4Titan

0

Thank you for your fast answer. I have not expected such an easy way :D Which osm tool do i have to use to query big amounts of data?

Maybe the overpass api is able to handle such volumes. https://overpass-api.de/api/interpreter?data=[out:json];out; But i have no idea how to do this query from above whit this api.

Is there anyone who is able to formulate the correct query?

...a query that uses the node id of a city/village to get its direct parent relations id (which is the city also)

https://overpass.kumi.systems/api/interpreter?data=[out:json];node( IdOfNode );<; filteringToGetTheParentRelationWhichDesribesAlsoTheCityOrVillage out;

I need this id to be able to use nominatim to get the borders of all cities in my database.

answered 29 Nov '17, 13:30

T4Titan's gravatar image

T4Titan
26113
accept rate: 0%

edited 30 Nov '17, 09:32

1

Which query? The main API is just an editing API and should not be used to perform large queries. Overpass API instead can handle rather large queries.

(29 Nov '17, 13:46) scai ♦
1

...a query that uses the node id of a city/village to get its direct parent relations id (which is the city also)

https://overpass.kumi.systems/api/interpreter?data=[out:json];node( IdOfNode );<; filteringToGetTheParentRelationIdOfTheRelationWhichDesribesAlsoTheCityOrVillage out;

(30 Nov '17, 09:33) T4Titan

Source code available on GitHub .