J.A
J.A

Reputation: 97

Correct way to use GeoPy Nominatim

I'm new on programing, and I'm using a programing tutorial which said that to use geopy like this:

import pandas, os, geopy
from geopy.geocoders import Nominatim

GeoLocator = Nominatim()

but after the last line I'm getting this error:

/usr/local/lib/python3.7/site-packages/geopy/geocoders/osm.py:143: UserWarning: Using Nominatim with the default "geopy/1.17.0" user_agent is strongly discouraged, as it violates Nominatim's ToS https://operations.osmfoundation.org/policies/nominatim/ and may possibly cause 403 and 429 HTTP errors. Please specify a custom user_agent with Nominatim(user_agent="my-application") or by overriding the default user_agent: geopy.geocoders.options.default_user_agent = "my-application". In geopy 2.0 this will become an exception. UserWarning

My question is, how should I change my code to fix this error?

Upvotes: 8

Views: 30948

Answers (2)

Andrew McDowell
Andrew McDowell

Reputation: 2980

You should specify a user_agent. The Nominatum service runs on donated servers which have limited capacity, so specifying a user-agent field allows Open Street Map to track more easily who is using their service. See here for a more detailed answer.

If you don't they may block your IP address from accessing the service as that would be a violation of their terms of service.

Upvotes: 10

Shivam Suchak
Shivam Suchak

Reputation: 229

nom = Nominatim(user_agent="http") you have to mention your useragent(HTTP) its just about IP adress

Upvotes: 9

Related Questions