Python 3 Script to Convert Location or Address to Latitude and Longitude Coordinates Using geopy Module

You are currently viewing Python 3 Script to Convert Location or Address to Latitude and Longitude Coordinates Using geopy Module

Python 3 Script to Convert Location or Address to Latitude and Longitude Coordinates Using geopy Module

# importing geopy library
from geopy.geocoders import Nominatim

# calling the Nominatim tool
loc = Nominatim(user_agent="GetLoc")

# entering the location name
getLoc = loc.geocode("Gosainganj Lucknow")

# printing address
print(getLoc.address)

# printing latitude and longitude
print("Latitude = ", getLoc.latitude, "n")
print("Longitude = ", getLoc.longitude)

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply