powered by
Calculate the great-circle distance between two points using the Haversine function.
haversine(lat1, lon1, lat2, lon2, r = 6371)
A numeric value of the distance between point 1 and 2 in kilometers.
The latitude of point 1 in degrees.
The longitude of point 1 in degrees.
The latitude of point 2 in degrees.
The longitude of point 2 in degrees.
The average earth radius.
fra <- c(50.03333, 8.570556) # Frankfurt Airport ord <- c(41.97861, -87.90472) # Chicago O'Hare International Airport haversine(fra[1], fra[2], ord[1], ord[2]) # 6971.059 km
Run the code above in your browser using DataLab