Learn R Programming

SpatialAcc (version 0.1-5)

distance: Distance Matrix Computation

Description

Computes Euclidean or Manhattan distances for all pairs of points between two sets of points.

Usage

distance(m1, m2, type = "euclidean")

Value

A distances matrix in which rows refer to origins and columns refer to destinations.

Arguments

m1

a vector referring to a set of origin point coordinates

m2

a vector referring to a set of destination point coordinates

type

the type of distance to be computed. Two types are currently supported "euclidean" and "manhattan".

Author

Stamatis Kalogirou <stamatis.science@gmail.com>

Details

When m1 and m2 are identical, the function is equivalent to the dist function of base R.

See Also

dist in stats.

Examples

Run this code
m1<-cbind(c(1:10),c(1:10))
m2<-cbind(sample(20:80,4),sample(20:80,4))
d<-distance(m1,m2)

Run the code above in your browser using DataLab