distm function

Distance matrix

Distance matrix

Distance matrix of a set of points, or between two sets of points 1.1

distm(x, y, fun=distGeo)

Arguments

  • x: longitude/latitude of point(s). Can be a vector of two numbers, a matrix of 2 columns (first one is longitude, second is latitude) or a SpatialPoints* object
  • y: Same as x. If missing, y is the same as x
  • fun: A function to compute distances (e.g., distCosine or distGeo)

Returns

Matrix of distances

References

https://en.wikipedia.org/wiki/Great_circle_distance

Author(s)

Robert Hijmans

See Also

distGeo, distCosine, distHaversine, distVincentySphere,distVincentyEllipsoid

Examples

xy <- rbind(c(0,0),c(90,90),c(10,10),c(-120,-45)) distm(xy) xy2 <- rbind(c(0,0),c(10,-10)) distm(xy, xy2)
  • Maintainer: Robert J. Hijmans
  • License: GPL (>= 3)
  • Last published: 2024-10-04

Useful links