我报废了一个网站以获取多个地方的地址,在我的列表中,我有街道地址,邮政编码/城市和州/国家,所以有3个不同的列,我无法弄清楚如何打开地址变成坐标。到目前为止,这是我的代码。它来自两次不同的尝试。
geolocator = Nominatim()
address_new = (street + ' ,' + zip + ' ,' + city)
location = geolocator.geocode(address_new)
if location:
lat = location.latitude
lon = location.longitude
geolocator = Nominatim()
with open("addresses", 'r') as fp:
for line in fp:
location = geolocator.geocode(line)
print(location.latitude, location.longitude)