Implementing distances using Python
The scenario on which we will implement the distance algorithms just described involves a dataset of US hotels, containing the latitude and longitude of each. The goal is to enrich the dataset by adding the distances to the nearest airports.
The hotel data is publicly available on Back4App (https://bit.ly/data-hotels-usa). For convenience, we extracted only 100 hotels from New York City and we will calculate for each of them the distances from the LaGuardia and John F. Kennedy airports (you can find the airport data here: https://datahub.io/core/airport-codes) using the Haversine (spherical model) and Karney (ellipsoidal model) methods. You can find the already extracted datasets for your convenience in the Chapter10
folder of the GitHub repository. In detail, you will find the hotel data in the hotels-ny.xlsx
file and the airport data in the airport-codes.csv
file.
Calculating distances with Python
As we mentioned earlier, we are not those...