Hi ! I have 1000 cities that I want to make a list of bboxes, where they fit in then to generate tiles for them 1 by 1. The problem is that manually to find out and insert in system database the bboxes are very time consuming and annoying. Is there any API that I can find out the city bbox ?? Lets say with geonames.org I can find the center of map, but how to find appropriate bbox ??? Any ideas? asked 09 Feb '13, 10:58 Gevork |
You could extract the boundary=administrative areas for the cities you want with the Overpass API (or XAPI, but that has more limitations on use), convert the .osm file to a shapefile, then use ogr to extract the bounding box. In python, all you'd need would be something like the following, which you could then write to a new file. Note that many of the boundaries will be relations, but you can query for those too.
answered 11 Feb '13, 14:55 neuhausr |
Adding to @neuhausr's answer, here is an example Overpass query to return the bounding box of the AU-NSW admin boundary, then you can see the bounding box in the Data tab at https://overpass-turbo.eu/.
answered 22 Dec '17, 01:49 aharvey |
If you want to have boundingboxes for ceratin places, there is so far no other way to define them manually, because there is no such information in the OSM data about boundingboxes around cities or places. BUT you can try to find boundary polygons for many cities that are stores in data relations within the OSM data. Go to http://nominatim.openstreetmap.org and type in a name of a wanted place. If the result list gives back a place with this special icon: ... then this can be the right boundary. Verify this by hand for some examples. In theory, now you can create a boundingbox where the boundary polygon is fitting in. Maybe it is even possible to run Nominatim in a kind of batch modus and to create that bboxes automatically. answered 11 Feb '13, 11:53 stephan75 |
You need to find the "city polygon", which may or may not be tagged as belonging to the city.
I think it is a very hard task to extract city bboxes from a OSM dataset. You could probably do this easier using some sort of national dataset provided by your national geographic agency.