Re: [R] Geographic distance between lat-long points in R?

From: dirknbr <dirknbr_at_gmail.com>
Date: Mon, 11 Apr 2011 08:44:22 -0700 (PDT)

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.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 11 Apr 2011 - 17:42:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 11 Apr 2011 - 17:50:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive