I would like to get the coordinates of a given city’s boundary to draw a polygon in Google map.
Currentky I do this by going to
and searching for a given city and then navigating to its details page and then getting the relation id of type ( boundary:administrative ).
Once after I get the relation id, I can go to
to get the coordinates in any format.
I would like to do this programmatically.
The first challenge that I am experiencing is - I am unable to get the boundary:administrative relation id of a given city.
Any advice would be highly appreciated.
I’m a bit uncomfortable about he reference to Google Maps. How are you adding the copyright notice for OSM to the result? Can you confirm that you are not adding anything to Google’s data based on the result and that you are not modifying the polygons based on anything within Google’s data.
City has different meanings in different countries.
Not all cities have suitably licensed boundaries, so not all cities will have bounding polygons on OSM.
Some cities may have boundaries directly as ways, not as relations.
There is always going to be a manual element in locating the city, as there is no manually maintained gazetteer of cities, and Nominatim will always need double checking.
The rest seems to be a simple matter of programming.