我想用geopy得到地址的纬度和经度。我的代码是
geolocator = Nominatim(user_agent="EXAMPLE")
location = geolocator.geocode("Wismarsche Straße 393-397 19049 Schwerin")
lat = str(location.latitude)
lon = str(location.longitude)
latLon = str(lat) + ";" + str(lon) + ";"并输出NoneType。
有人知道为什么吗?
发布于 2020-04-26 22:55:09
documentation声明当找不到任何结果时,地理编码方法返回None。在您的示例中,从查询中删除19049将返回一个结果:
location = geolocator.geocode("Wismarsche Straße 393-397 Schwerin")
lat = str(location.latitude)
lon = str(location.longitude)
latLon = str(lat) + ";" + str(lon) + ";"
print(f'Latitude: {lat}, longitude: {lon}, latLon: {latLon}')输出:
Latitude: 53.6519479, longitude: 11.4073671, latLon: 53.6519479;11.4073671;https://stackoverflow.com/questions/61440533
复制相似问题