Learn R Programming

SpatialExtremes (version 2.0-7)

distance: Computes distance between pairs of locations

Description

This function computes euclidean distance or distance vector for each pair of a set of spatial locations.

Usage

distance(coord, vec = FALSE)

Arguments

coord

A matrix representing the coordinates of each locations. Each row corresponds to one location.

vec

Logical. If FALSE (default), the euclidean distance is computed. Otherwise, ``distance vectors'' are returned.

Value

If vec = FALSE, this function returns a vector that gives the euclidean distance for each pair of locations. Otherwise, this is a matrix where each column correspond to one dimension - i.e. longitude, latitude, …

See Also

dist

Examples

Run this code
# NOT RUN {
coords <- cbind(seq(0, 10, by = 2), seq(10, 0, by = -2))
distance(coords)
distance(coords, vec = TRUE)
# }

Run the code above in your browser using DataLab