View source: R/location_functions.R
haversine | R Documentation |
Calculate the great-circle distance between two points using the Haversine function.
haversine(lat1, lon1, lat2, lon2, r = 6371)
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. |
A numeric value of the distance between point 1 and 2 in kilometers.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.