haversine {rSDI} | R Documentation |
Calculate Haversine Distance Between Two Points on Earth
Description
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.
Usage
haversine(lon1, lat1, lon2, lat2, R = 6371)
Arguments
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. |
Value
The distance between the two points in kilometers.
Examples
haversine(-73.9851, 40.7580, -0.1278, 51.5074)
# Distance between NY City and London.
[Package rSDI version 0.2.1 Index]