{"id":26612,"date":"2022-04-02T20:15:41","date_gmt":"2022-04-02T14:45:41","guid":{"rendered":"https:\/\/python-programs.com\/?p=26612"},"modified":"2022-04-02T20:15:41","modified_gmt":"2022-04-02T14:45:41","slug":"how-to-get-geolocation-in-python-using-geopy","status":"publish","type":"post","link":"https:\/\/python-programs.com\/how-to-get-geolocation-in-python-using-geopy\/","title":{"rendered":"How to Get Geolocation in Python using GeoPy?"},"content":{"rendered":"

What is Geolocation?<\/strong><\/p>\n

Geolocation refers to a physical location. It identifies and tracks the location of linked electronic devices using various location technologies such as GPS and IP addresses.<\/p>\n

Python’s GeoPy module is used for this purpose. When you enter a location name, it returns all info such as the postal code, city, state, and nation, as well as latitudes and longitudes. When we enter the coordinates, it returns the name of the location.<\/p>\n

GeoPy is not a built-in Python library. It must be explicitly installed.<\/p>\n

Installation:<\/strong><\/p>\n

\n
pip\u00a0install\u00a0geopy<\/pre>\n

Installation in Anaconda:<\/strong><\/p>\n

conda install geopy<\/pre>\n

Every geolocation service, such as Google Maps or Nominatim, has its own class in geopy.geocoders that are used to abstract the API of the service. We’ll be using Nominatim, a free API service tool, in this case.<\/p>\n

Geocodes of some places in India:<\/strong><\/p>\n

Place\u00a0<\/strong> \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Latitude\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0Longitude<\/strong><\/p>\n

Telangana, India\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a017.123184\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a079.208824<\/p>\n

Kerala, India\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a010.850516\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a076.271080<\/p>\n

Tamil Nadu, India\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a011.127123\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a078.656891<\/p>\n

Getting Geolocation in Python using GeoPy<\/h2>\n