Learn R Programming

letsR (version 5.0)

lets.distmat: Compute a geographic distance matrix

Description

Calculates a geographic distance matrix based on a PresenceAbsence or a two column matrix of x(longitude) and y(latitude).

Usage

lets.distmat(xy, asdist = TRUE)

Value

The user can choose between dist and matrix class object to be returned. The resulting values are in kilometres (but see the argument 'unit' in rdist.earth).

Arguments

xy

A PresenceAbsence object or a matrix with two columns (longitude, latitude).

asdist

Logical, if TRUE the result will be an object of class dist, if FALSE the result will be an object of class matrix.

Author

Bruno Vilela & Fabricio Villalobos

Details

This function basically facilitates the use of terra::distance on a PresenceAbsence object, allowing also the user to have directly a dist object. The distance is always expressed in meter if the coordinate reference system is longitude/latitude, and in map units otherwise. Map units are typically meter, but inspect crs(x) if in doubt.

Examples

Run this code
if (FALSE) {
data(PAM)
distPAM <- lets.distmat(PAM)
}

Run the code above in your browser using DataLab