extract_distances {TDLM} | R Documentation |
Compute the distance between pairs of locations
Description
This function computes the distance between pairs of locations based on geographical coordinates.
Usage
extract_distances(
coords,
method = "Haversine",
id = NULL,
show_progress = FALSE
)
Arguments
coords |
A two-column |
method |
A |
id |
A vector with length equal to the number of locations, used as
row names and column names for the output distance matrix (optional, |
show_progress |
A boolean indicating whether a progress bar should be displayed. |
Details
coords
must contain two columns: the first one for the longitude
or "X" coordinates, and the second one for the latitude or "Y" coordinates.
The "Haversine"
method is used to compute great-circle distances from
longitude/latitude, while the "Euclidean"
method should be used for "X/Y"
coordinates.
Value
A square matrix representing the distance (in kilometers) between locations.
Note
The outputs are based on the locations contained in coords
, sorted
in the same order. An optional id
can also be provided to be used as
names for the outputs.
Author(s)
Maxime Lenormand (maxime.lenormand@inrae.fr)
See Also
Associated functions: extract_opportunities()
Examples
data(coords)
distance <- extract_distances(coords = coords,
method = "Haversine",
id = rownames(coords))