Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

distm

Distance matrix


Description

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

Usage

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)

Value

Matrix of distances

Author(s)

Robert Hijmans

References

See Also

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)

geosphere

Spherical Trigonometry

v1.5-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut], Ed Williams [ctb], Chris Vennes [ctb]
Initial release
2019-05-25

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.