Skip to content
Related Articles

Related Articles

Find the location with specified latitude and longitude using Python
  • Last Updated : 11 Oct, 2020

In this article, we are going to write a python script to find the address of a specified latitude and longitude using the geopy module. The geopy module makes it easier to locate the coordinates of addresses, cities, countries, landmarks, and zipcode.

Installation:

To install GeoPy module, run the following command in your terminal.

pip install geopy

Step-by-step Approach:

  • Import the geopy module.
  • Initialize Nominatim API to get location from the input string.
  • Get location with geolocator.geocode() method.

Below is the program based on the above approach:



Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# Import module
from geopy.geocoders import Nominatim
  
# Initialize Nominatim API
geolocator = Nominatim(user_agent="geoapiExercises")
  
# Assign Latitude & Longitude
Latitude = "25.594095"
Longitude = "85.137566"
  
# Dsiaplying Latitude and Longitude
print("Latitude: ", Latitude)
print("Longitude: ", Longitude)
  
# Get location with geocode
location = geolocator.geocode(Latitude+","+Longitude)
  
# Dsiplay location
print("\nLocation of the given Latitude and Longitude:")
print(location)

chevron_right


Output:

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :