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

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

I found something here

#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)


View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
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 Please read the posting guide before posting to the list.

list of date sections of archive