当我使用geopy根据经纬度计算两个地址之间的距离时,对于单个数据对,它可以正常运行。但是对于更多的数据,总是会给我这个错误信息:
``` File "/Library/Python/2.7/site-packages/geopy/geocoders/osm.py", line 193, in geocode self._call_geocoder(url, timeout=timeout), exactly_one File "/Library/Python/2.7/site-packages/geopy/geocoders/base.py", line 171, in _call_geocoder raise GeocoderServiceError(message) geopy.exc.GeocoderServiceError: urlopen error [Errno 65] No route to host ```
你知道该如何避免这个问题吗?
我的代码很简单:(输入的数据中有许多数据对)
``` File "/Library/Python/2.7/site-packages/geopy/geocoders/osm.py", line 193, in geocode self._call_geocoder(url, timeout=timeout), exactly_one File "/Library/Python/2.7/site-packages/geopy/geocoders/base.py", line 171, in _call_geocoder raise GeocoderServiceError(message) geopy.exc.GeocoderServiceError: urlopen error [Errno 65] No route to host ```
你知道该如何避免这个问题吗?
我的代码很简单:(输入的数据中有许多数据对)
from geopy.geocoders import Nominatim
from geopy.distance import vincenty
def calculate_distance(add1, add2):
geolocator = Nominatim()
location1 = geolocator.geocode(add1)
al1 = (location1.latitude, location1.longitude)
location2 = geolocator.geocode(add2)
al2 = (location2.latitude, location2.longitude)
distce = vincenty(al1, al2).miles
return distce