[R-sig-Geo] inter-point distance calcs

Dylan Beaudette debeaudette at ucdavis.edu
Mon Aug 10 18:54:47 CEST 2009


On Monday 10 August 2009, Jim Bouldin wrote:
> Can anyone recommend a package that can calculate the distances between
> points (either all or a defined sample of) for x,y point locations listed
> in long format?  Thanks in advance.
>

Sure. How about the function dist():

d <- data.frame(x=sample(1:10, 5), y=sample(1:10, 5))

dist(d)
         1        2        3        4
2 3.605551                           
3 6.403124 7.071068                  
4 9.219544 7.211103 5.830952         
5 8.062258 5.099020 7.211103 3.162278


Cheers,
Dylan


-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341



More information about the R-sig-Geo mailing list