Closed simonw closed 3 years ago
Output for that San Francisco one:
[
{
"place_id": 257346022,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
"osm_type": "relation",
"osm_id": 111968,
"boundingbox": [
"37.6403143",
"37.929811",
"-123.173825",
"-122.281479"
],
"lat": "37.7790262",
"lon": "-122.4199061",
"display_name": "San Francisco, California, United States",
"class": "boundary",
"type": "administrative",
"importance": 0.9251309463713038,
"icon": "https://nominatim.openstreetmap.org/ui/mapicons//poi_boundary_administrative.p.20.png"
}
]
Note that the boundingbox
array doesn't come back in the min-lon,min-lat,max-lon,max-lat
format that we need to pass to Landez. It looks like it's lat1,lat2,lon1,lon2
.
Landez already uses requests
so I'll use that.
Looking up bounding boxes is a hassle. Nominatim provides an API, documented at https://nominatim.org/release-docs/latest/api/Search/ which can be used to look up the bounding boxes of specific addresses, cities and countries.
The
city=
andcountry=
APIs are particularly relevant here: