[R] Geographic distance between lat-long points in R?
dirknbr
dirknbr at gmail.com
Mon Apr 11 17:44:22 CEST 2011
I found something here
http://www.biostat.umn.edu/~sudiptob/Software/distonearth.R
#The following program computes the distance on the surface of the earth
between two points point1 and point2. Both the points are of the form
(Longitude, Latitude)
geodetic.distance <- function(point1, point2)
{
R <- 6371
p1rad <- point1 * pi/180
p2rad <- point2 * pi/180
d <-
sin(p1rad[2])*sin(p2rad[2])+cos(p1rad[2])*cos(p2rad[2])*cos(abs(p1rad[1]-p2rad[1]))
d <- acos(d)
R*d
}
Dirk
--
View this message in context: http://r.789695.n4.nabble.com/Geographic-distance-between-lat-long-points-in-R-tp3442338p3442355.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list