How to get the district/city/municipality given a gps position as well as the corresponding polygon

Hey everyone,

I would like to get the boundary as a geojson file or something similar given the gps info of a point and then extracting the district, city, municipality

So far I found out about nominatim to get data like the municipality now I’m wondering how I get the polygon from this information.

The info I get from nominatim is the following:

{"place_id":100891653,"licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://osm.org/copyright","osm_type":"way","osm_id":6243831,"lat":"59.385659776299605","lon":"18.30840420631662","class":"highway","type":"residential","place_rank":26,"importance":0.10000009999999993,"addresstype":"road","name":"Karlsuddsvägen","display_name":"Karlsuddsvägen, Karlsudd, Vaxholm, Vaxholms kommun, Stockholm County, 185 33, Sweden","address":{"road":"Karlsuddsvägen","hamlet":"Karlsudd","town":"Vaxholm","municipality":"Vaxholms kommun","county":"Stockholm County","ISO3166-2-lvl4":"SE-AB","postcode":"185 33","country":"Sweden","country_code":"se"},"boundingbox":["59.3833860","59.3878843","18.2967468","18.3278196"]}

using: https://nominatim.openstreetmap.org/reverse?format=json&lat=59.3855&lon=18.3084

Thanks in advance for any further pointers to get the boundaries.

1 Like

Do you know the overpass api?

Have you used that api to find a relation that your coordinate is inside?

Have you checked that relation for the admin_level or border tag to find your city, district or municipality?

See Overview - Nominatim Documentation (yes you can get the polygon), the nice thing about Nominatim is that it builds as far as possible hierarchies from the OSM data.

I’ve just started with the overpass api today a bit. I’m unsure how to get the admin levels from the data like town or municipality that I got from nominatim.

What admin_level are you looking for? Relations are tagged with admin_level. This relation has the admin_level of the state Lower Saxony and this of the city Hannover.

Please make sure that the admin_levels differ from nation to nation.

Yes that is the current problem I’m having as I would like to get the boundaries of all the levels mentioned in here:

So from Vaxholm, Vaxholms kommun as well as from Stockholm County and potentially of Sweden as well. I read that the admin_level depends on the country but is there a mapping to see that admin_level for municipality is 7 for example?