| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
This Python script calculates the geodesic distance between two geographic coordinates and estimates travel time based on a given average speed. It uses the geopy library to compute distances.
Clone the repository
git clone https://github.com/king04aman/All-In-One-Python-Projects.git
cd All-In-One-Python-Projects/Geographic DistanceCreate and activate a virtual environment
For macOS/Linux:
python3 -m venv venv
source venv/bin/activateFor Windows:
python -m venv venv
venv\Scripts\activateInstall the required dependencies
The required packages are listed in requirements.txt. Install them using the following command:
pip install -r requirements.txtNote: The main dependency is geopy for calculating distances based on geodesic coordinates.
Run the script:
python geographic_distance.pyEnter the coordinates (latitude and longitude) of the two locations when prompted.
Enter the average speed in km/h to calculate the travel time.
Example input:
Enter the latitude and longitude of the first location (lat1, lon1) Example: 40.7128, -74.006: 52.5200, 13.4050 Enter the latitude and longitude of the second location (lat2, lon2) Example: 37.7749, -122.4194: 48.8566, 2.3522 Enter the average speed in km/h Example: 60: 80
Example output:
Distance between the two coordinates: 878.84 kilometers Estimated travel time: 10.99 hours
Here’s a list of Python dependencies in requirements.txt:
geopy==2.2.0 pytest==8.3.3
| Back | FazBrowse Home | New Git URL |