distance: Distance Matrix Computation

View source: R/distance.R

distanceR Documentation

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")

Arguments

m1

a matrix or data frame containing origin point coordinates in the first two columns.

m2

a matrix or data frame containing destination point coordinates in the first two columns.

type

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

Details

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

Value

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

Author(s)

Stamatis Kalogirou <stamatis.science@gmail.com>

See Also

dist in stats.

Examples

m1 <- cbind(1:10, 1:10)
m2 <- cbind(c(20, 40, 60, 80), c(25, 45, 65, 85))
d <- distance(m1, m2)

SpatialAcc documentation built on April 29, 2026, 1:08 a.m.