![[Stable]](figures/lifecycle-stable.svg)
Calculate the great-circle distance between two points using the Haversine function.
Usage
haversine(lat1, lon1, lat2, lon2, r = 6371)
Arguments
- lat1
The latitude of point 1 in degrees.
- lon1
The longitude of point 1 in degrees.
- lat2
The latitude of point 2 in degrees.
- lon2
The longitude of point 2 in degrees.
- r
The average earth radius.
Value
A numeric value of the distance between point 1 and 2 in kilometers.
Examples
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
#> [1] 6971.059