[R] Calculating great circle distances

Roger Bivand Roger.Bivand at nhh.no
Wed Nov 26 08:27:53 CET 2003


On Wed, 26 Nov 2003 Toby.Patterson at csiro.au wrote:

> Hi, 
> Has anyone got any R code (or are there any packages) that calculates
> the great circle distance between two geographical (lat, lon) positions?
> 

Yes, there is R code in fields, function rdist.earth() taking vectors as
arguments for one solution, alternatively there is a C function in spdep:

void gcdist(double *lon1, double *lon2, double *lat1, double *lat2, 
		double *dist)

which needs to be put in a loop, but is specifically WGS84, and is based 
on the implementation at:

http://home.att.net/~srschmitt/greatcircle.html

There may be other code too.

Roger

> 
> Cheers 
> 
> Toby Patterson 
> Pelagic Ecosystems Research Group
> CSIRO Marine Research 
> Email: Toby.Patterson at csiro.au
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list