data(ozone2)
out<- rdist.earth ( ozone2$lon.lat)
#out is a 153X153 distance matrix
out2<- RdistEarth ( ozone2$lon.lat)
all.equal(out, out2)
upper<- col(out)> row( out)
# histogram of all pairwise distances.
hist( out[upper])
#get pairwise distances between first 10 and second 10 lon/lat points
x1 = ozone2$lon.lat[1:10,]
x2 = ozone2$lon.lat[11:20,]
dists = rdist.earth.vec(x1, x2)
print(dists)
Run the code above in your browser using DataLab