将查询地理定位到地址和坐标:
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="specify_your_app_name_here")
location = geolocator.geocode("175 5th Avenue NYC")
print(location.address)
Flatiron Building, 175, 5th Avenue, Flatiron, New York, NYC, New York, ...
print((location.latitude, location.longitude))
(40.7410861, -73.9896297241625)
print(location.raw)
{'place_id': '9167009604', 'type': 'attraction', ...}
找到一组坐标对应的地址:
from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="specify_your_app_name_here")
location = geolocator.reverse("52.509669, 13.376294")
print(location.address)
Potsdamer Platz, Mitte, Berlin, 10117, Deutschland, European Union
print((location.latitude, location.longitude))
(52.5094982, 13.3765983)
print(location.raw)
{'place_id': '654513', 'osm_type': 'node', ...}
https://geopy.readthedocs.io/en/stable/