使用python从给定坐标获取地址

Ano*_*ous 5 python coordinates street-address visual-studio-code

我有一些经纬度坐标,我想使用 Python 将其转换为特定地址。你知道怎么做吗?谢谢你我是新来的。

Her*_*wid 11

您所说的方法称为反向地理编码。您可以使用 Nominatim (OSM) 获得免费地理编码服务

from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="specify_your_app_name_here")
location = geolocator.reverse("52.509669, 13.376294")
print(location.address)
Run Code Online (Sandbox Code Playgroud)

或者,如果您想获得更好的结果,您可以使用需要 API Key 的 Google Geocode 服务

from geopy.geocoders import GoogleV3
geolocator = GoogleV3(api_key='Your_API_Key')
location = geolocator.reverse("52.509669, 13.376294")
print(location.address)
Run Code Online (Sandbox Code Playgroud)