find_dists {mcgf} | R Documentation |
Calculate (signed) distances between coordinates
Description
Calculate (signed) distances between coordinates
Usage
find_dists(locations, longlat = TRUE, origin = 1L, return_grid = FALSE, ...)
Arguments
locations |
A matrix or data.frame of 2D points, the first column is x/longitude, and the second column is y/latitude. |
longlat |
Logical, if TURE Great Circle (WGS84 ellipsoid) distance; if FALSE, Euclidean distance. |
origin |
Optional; used when |
return_grid |
Logical; used when |
... |
Optional arguments passed to |
Details
locations
must be a matrix or data.frame containing 2 columns,
first column x/longitude, and second column y/latitude. The row names of
locations
are used as the names of the locations.
If longlat
is TRUE, the original coordinates are mapped to a 2D Euclidean
plane given the reference location. First, the Great Circle (WGS84 ellipsoid)
signed distance matrices are calculated, where the original latitudes are
replaced by the the mean of them to find the signed longitudinal
distances and the original longitudes are replaced by the the mean of them
to find the signed latitudinal distances. Then given the index of a
reference location origin
, a new set of coordinates in a 2D plane is
generated where the coordinates are determined by the signed distances
between the locations and the reference location. Finally distance matrices
of the new coordinates are outputted.
Value
A list of distance matrices. If return_grid
is TRUE, a list
consists of a list of distance matrices, the mapped 2D grid, and the origin
is returned.
Examples
lon <- c(110, 120, 130)
lat <- c(50, 55, 60)
locations <- cbind(lon, lat)
rownames(locations) <- paste("Site", 1:3)
find_dists(locations)