Learn R Programming

SpatialTools (version 0.3.2)

dist2: Calculates Euclidean distance between coordinates of two matrices

Description

Calculates Euclidean distance between the coordinates of coords1 and coords2 matrices. It is assumed that coords1 and coords2 have the same number of columns but not necessarily the same number of rows.

Usage

dist2(coords1, coords2)

Arguments

coords1
A matrix of dimensions $nr1\times nc$
coords2
A matrix of dimensions $nr2\times nc$

Value

  • dist2 returns a matrix of size $nr1\times nr2$ containing the Eucliean distances between each pair of coordinates in coords1 and coords2.

See Also

dist1

Examples

Run this code
x1 <- matrix(rnorm(30), ncol = 3)
	x2 <- matrix(rnorm(60), ncol = 3)
	dist2(x1, x2)

Run the code above in your browser using DataLab