latlong=TRUE
) or on a plane (latlong=FALSE
).pointDistance(p1, p2, longlat=FALSE, ...)
p1
. If p1
and p2
are both matrices they should have the same number of rows. If this argument is missing, a distance matrix is computed for p1
TRUE
, coordinates should be in degrees; else they should represent planar ('Euclidean') space (e.g. units of meters)r
, of the world (modeled as a sphere), when longlat=TRUE
Default is r=6378137
p2
is missing, a distance matrix is returneddistanceFromPoints, distance, gridDistance, spDistsN1
a <- cbind(c(1,5,55,31),c(3,7,20,22))
b <- cbind(c(4,2,8,65),c(50,-90,20,32))
pointDistance(c(0, 0), c(1, 1), longlat=FALSE)
pointDistance(c(0, 0), c(1, 1), longlat=TRUE)
pointDistance(c(0, 0), a, longlat=TRUE)
pointDistance(a, b, longlat=TRUE)
#Make a distance matrix
dst <- pointDistance(a, longlat=TRUE)
# coerce to dist object
dst <- as.dist(dst)
Run the code above in your browser using DataLab