Geopy返回HTTP错误400:错误的请求

问题描述

我正在使用geopy软件包来获取位置地理代码,但始终运行到HTTP Error 400: Bad Request

下面是我的代码,该代码遵循官方文档https://geopy.readthedocs.io/en/stable/

from geopy.geocoders import ArcGIS
geolocator = ArcGIS(scheme="http")
loc_home = geolocator.geocode("175 5th Avenue NYC")

以下是错误

geopy.exc.GeocoderQueryError: HTTP Error 400: Bad Request

请先帮助并感谢!

解决方法

您需要使用https方案,我猜http被ArcGIS阻止了。

from geopy.geocoders import ArcGIS
geolocator = ArcGIS(scheme="https")

geolocator.geocode("175 5th Avenue NYC")

#Location(175 5th Ave,New York,10010,(40.741110006692395,-73.98968797828522,0.0))