[GIS] GeoPy API error: GeocoderInsufficientPrivileges

geopynominatim

Continually receiving error from standard address geolocation request using Nominatim.

Code below:

from geopy.geocoders import Nominatim
address = "90, Park Avenue, New York City, New York, 10016"
geolocator = Nominatim(address, timeout=10, exactly_one=False)
location = geolocator.geocode(address, timeout=10, exactly_one=False)

Resulting error below:

Traceback (most recent call last):
    File "<input>", line 1, in <module>
    File ".../lib/python2.7/site-packages/geopy/geocoders/osm.py", line 176, in geocode
    self._call_geocoder(url, timeout=timeout), exactly_one
    File ".../lib/python2.7/site-packages/geopy/geocoders/base.py", line 147, in call_geocoder
    raise ERROR_CODE_MAP[code](message)
    GeocoderInsufficientPrivileges: HTTP Error 403: Forbidden

Question: The docs only acknowledge this occurs but does not prevent it (https://geopy.readthedocs.org/en/1.9.1/#geopy.exc.GeocoderInsufficientPrivileges). They wrote,

"The remote geocoding service refused to fulfill a request using the
account credentials given."

What can I do to avoid this?

Best Answer

This will work:

    from geopy.geocoders import Nominatim
    address = "90, Park Avenue, New York City, New York, 10016"
    geolocator = Nominatim()
    location = geolocator.geocode(address, timeout=10, exactly_one=False)

Location returned:

    [Location((40.7504506, -73.979202, 0.0)), Location((40.7508392, -73.9789244, 0.0)), Location((40.750799, -73.9789457, 0.0)), Location((40.7507393, -73.9794361059, 0.0))]