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

I want to query the municipality (city or town) a given point is in, but not only its name, but also the OpenStreetMap id of the area of that city/town in order to fetch further tags from that city/town and to uniquely identify it.

For example, for the node with the id 3127879237 (located in Vienna, Austria) I would like to get back the id 3600109166 for the area of Vienna.

With Overpass and Nominatim, i could only achieve that half-way so far:

Using Overpass the following query returns all surrounding boundaries:


One of them is the city/town boundary I am looking for, but it doesn't have any tags signalling it's the city/town and it seems like the admin_level of the municipality depends on its size and the country.

Nominatim can figure out the city/town, but it only gives back its name, which is not necessarily unique, and not its OSM-id:

Is the only way to achieve that to get the name from Nominatim and then filtering the is_in results by the name returned from Nominatim?

asked 09 Mar '21, 11:51

Loram's gravatar image

accept rate: 0%

Nominatim's /details endpoint can return a list of parent objects, each with name, osmtype, osmid. Ignore any items having isaddress=false. That can help you when you run your own Nominatim server. For the public the access is discouraged as it puts a higher load on the database

permanent link

answered 09 Mar '21, 12:06

mtmail's gravatar image

accept rate: 27%

As with this example many place=city/town entities are nodes. If you're unable to rely on admin_level, you'll need to iterate the returned boundary relations to return nodes with 'admin_centre' roles. These should contain 'place=city/town'. Try expanding on this:

out geom;
permanent link

answered 09 Mar '21, 13:57

DaveF's gravatar image

accept rate: 16%

edited 09 Mar '21, 15:26

Thanks a lot! However, for other points, this query also returns the capital cities of the states and nations the point is in. The only way to filter the actual city the node is in that came to my mind is to pick the output city that is nearest to the given point in a post-processing step. Is there also a way to exclude the others from the query?

(14 Jul '21, 20:01) Loram

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 09 Mar '21, 11:51

question was seen: 2,559 times

last updated: 14 Jul '21, 20:02

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