haversine | R Documentation |
This function calculates the great-circle distance between two points on the Earth's surface, given their longitude and latitude in decimal degrees. It uses the Haversine formula, which accounts for the Earth's curvature.
haversine(lon1, lat1, lon2, lat2, R = 6371)
lon1 |
Longitude of the first point in decimal degrees. |
lat1 |
Latitude of the first point in decimal degrees. |
lon2 |
Longitude of the second point in decimal degrees. |
lat2 |
Latitude of the second point in decimal degrees. |
R |
The radius of the Earth in kilometers. |
The distance between the two points in kilometers.
haversine(-73.9851, 40.7580, -0.1278, 51.5074)
# Distance between NY City and London.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.