Skip to content

Commit f9646df

Browse files
author
SATYAM TRIPATHI
authored
Add files via upload
1 parent a82c450 commit f9646df

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Import following modules
2+
from geopy.geocoders import Nominatim # pip install geopy
3+
from geopy.distance import geodesic
4+
# Link the user_agent to Google Map, so tat it can calculate latitude and longitude
5+
geolocator = Nominatim(user_agent="https://maps.google.com")
6+
fro = input("From: ") # From which City
7+
to = input("To: ") # To which city
8+
location = geolocator.geocode(fro) # Fetch all the data of the city
9+
locate = geolocator.geocode(to)
10+
# Extract longitude and latitude
11+
newport_ri = (location.latitude, location.longitude)
12+
cleveland_oh = (locate.latitude, locate.longitude)
13+
# Display the distance in KiloMeters
14+
print(geodesic(newport_ri, cleveland_oh).km)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip install geopy

0 commit comments

Comments
 (0)