Skip to content

Geographic distance between lat-long points in R?

8 messages · Scott Chamberlain, dirknbr, Eik Vettorazzi +2 more

#
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.
#
Hi Scott,
have a look at the 'earth.dist'-function in the package 'fossil'.

hth.

Am 11.04.2011 17:37, schrieb Scott Chamberlain:

  
    
6 days later
3 days later