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

Hello.

There are cities without relations. 'Search results' shows path of relations. How to get relation_ids from this path?

For example I am looking for 'Wislon'. In Search results I see City: 'Wilson, Wilson County, North Carolina, United States of America', ie Wilson is part of Wilson County and Wilson County is part of North Carolina and so on. If I go to the details of the city (click the link), at the bottom of the page I see there is no any relation.

How can I get relation_ids for Wilson County, North Carolina, United States of America? Usually I use http://www.openstreetmap.org/api/0.6/relation/relation_id, but this is not the case.

As I can guess, this path is based on latitude\longitude of a place, and map\engine checks the next bigger territory untill the country level is reached. Is there any API call which I can use to get relation_ids of this tree? Thank you.

asked 06 May '16, 22:42

bear_ukraine's gravatar image

bear_ukraine
41336
accept rate: 0%

edited 06 May '16, 22:53


The county relation is available:

http://www.openstreetmap.org/relation/2528757

To obtain the county relation from another object, you could synthesize a coordinate for the object (maybe the center or use some method to select a child node) and use reverse geocoding to obtain the admin hierarchy for that point. Nominatim and Overpass API both have support for such queries:

http://wiki.openstreetmap.org/wiki/Nominatim#Reverse_Geocoding

http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Query_for_areas_.28is_in.29

permanent link

answered 06 May '16, 23:08

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

1

Your information + some additional search + re-read few times Overpass API (lack of examples) and I have finally what I want :) Nominatim is cool thing, lots of example, but lack of functionality :)

Here is the example of the solution: http://overpass-api.de/api/interpreter?data=rel(4084902);>;is_in;out;

Also related info: http://help.openstreetmap.org/questions/20053/locating-an-osm-object-eg-finding-town-relation-name/20055

(07 May '16, 00:11) bear_ukraine
1

Don't miss Overpass Turbo when working Overpas API queries.

(07 May '16, 02:31) maxerickson

Alternatively, you could go to http://nominatim.openstreetmap.org. Search for Wilson, pick the one you want, click on details and you get a page like http://nominatim.openstreetmap.org/details.php?place_id=144418235

On that page you will find all the links of the relations used by Nominatim to calculate the address.

permanent link

answered 07 May '16, 11:13

escada's gravatar image

escada
19.0k16166302
accept rate: 21%

Wow. This method is also cool. Is there any way how can I get the data from details page via API?

(07 May '16, 13:22) bear_ukraine

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

question asked: 06 May '16, 22:42

question was seen: 1,873 times

last updated: 07 May '16, 13:22

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