Search code examples
pythongoogle-mapsgeopy

Geopy Returns HTTP Error 400: Bad Request


I am using geopy package to get the location geocode but always run to the HTTP Error 400: Bad Request.

Below is my code, which follows the official document https://geopy.readthedocs.io/en/stable/:

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

Below is the error:

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

Please help and thanks in advance!


Solution

  • You'll need to use https scheme, I guess the http is blocked by 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))