Description Usage Arguments Value Author(s) Examples
Compute the distance between two points
1 | deg.dist(long1, lat1, long2, lat2)
|
long1 |
Longitude at point of origin |
lat1 |
Latitude at point of origin |
long2 |
Longitude at destination point |
lat2 |
Latitude at destination point |
A distance in kilometers
From fossil package
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | library(PWS)
myDist = deg.dist(-84.3880556, 33.7488889, -83.3779358, 33.960948)
## The function is currently defined as
function (long1, lat1, long2, lat2)
{
rad <- pi/180
a1 <- lat1 * rad
a2 <- long1 * rad
b1 <- lat2 * rad
b2 <- long2 * rad
dlon <- b2 - a2
dlat <- b1 - a1
a <- (sin(dlat/2))^2 + cos(a1) * cos(b1) * (sin(dlon/2))^2
c <- 2 * atan2(sqrt(a), sqrt(1 - a))
R <- 40041.47/(2 * pi)
d <- R * c
return(d)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.