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 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 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 asked 09 Mar '21, 11:51 Loram |
Nominatim's /details endpoint can return a list of parent objects, each with name, osmtype, osmid. https://nominatim.openstreetmap.org/details?osmtype=N&osmid=3127879237&format=json&addressdetails=1 Ignore any items having isaddress=false. That can help you when you run your own Nominatim server. For the public nominatim.openstreetmap.org the access is discouraged as it puts a higher load on the database https://nominatim.org/release-docs/develop/api/Details/ answered 09 Mar '21, 12:06 mtmail |
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:
answered 09 Mar '21, 13:57 DaveF 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
|