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

Given a node number or a way number, typically a street but also any object, what are the API, XAPI or overpass API HTTP queries to send, and what is the algorithm to process the replies, to determine the relation number of which municipality, province, country, landuse, whichever polygon, etc... which that object is inside? Only OSM data must be used via the Web. But this may of course be best translatable to a query system of local OSM data, notably inside a mobile device without dialing external sources.
Typical use:
"you are here": given coordinates of where, find municipality boundary and write its name after street name.
POI list: same question for each coordinates of a collected list of POIs, e.g. to add town name to each entry.

asked 20 Feb '13, 04:28

GentilPapou's gravatar image

GentilPapou
160146
accept rate: 0%


In general, you can get the areas

  • of a given node with: node(ID);is_in;out;
  • of a given way with: way(ID);>;is_in;out;
  • of a given relation with: rel(ID);>;is_in;out;
  • or of a given coordinate with: is_in(LAT,LON);out;

In all cases, you need to replace ID with the object id, or LAT and LON with latitude and longitude. You need to prepend http://overpass-api.de/api/interpreter?data= to get a full URL.

For more details, you can have a look at the documentation of the is_in statement. To make sense of the returned data, you may need to read the documentation of the admin_level key.

permanent link

answered 20 Feb '13, 06:56

Roland%20Olbricht's gravatar image

Roland Olbricht
6.7k36489
accept rate: 36%

Very, very neat answer, thanks a lot.
I suggest actually working examples below the documentation of those statements. It's always easier to start from a working command towards what you want and get back when it stops working than to start with a non working command ;-)

(08 Mar '13, 18:26) GentilPapou

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:

×128
×11
×5
×2

question asked: 20 Feb '13, 04:28

question was seen: 5,552 times

last updated: 08 Mar '13, 18:28

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