File tree 2 files changed +15
-0
lines changed
BasicPythonScripts/Distance Finder
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
1
+ pip install geopy
You can’t perform that action at this time.
0 commit comments