Calculate the nearest airport of each zipcode using Python. Based on Haversine formula
Keywords: Python, Pandas, Geographical Data, Geography
Business Use Case
- Sales Territory Planning
- Determine if any targeted location can easily be accessed.
- CSV file per state/region, which contains the following:
- All zipcodes
- Nearest airport (code, lat and long) of each zipcode
Sample Data: 90210, California
Out of 558 airports in California, what's the nearest airport to Beverly Hills, LA?
Based on the script, the nearest airport to 90210 is: KSMO is Santa Monica Municipal Airport
Let's validate the model by plotting in Google Maps:
The black line indicates the distance of 9.20 km from 90210 to the airport, which is close to 9.22km!
Note that the formula doesn't consider the actual roads in the location. Haversine simply calculates the distance from point A to point B.
Now, here's the second nearest airport: Bob Hope Airport (KBUR)
- Distance based on Haversine: 13.05 km
- Distance based on Google Maps 13.03 km
- Add Part 2: travelability scores through Pandas binning