View source: R/extract_distances.R
extract_distances | R Documentation |
This function computes the distance between pairs of locations based on geographical coordinates.
extract_distances(
coords,
method = "Haversine",
id = NULL,
show_progress = FALSE
)
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. |
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.
A square matrix representing the distance (in kilometers) between locations.
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.
Maxime Lenormand (maxime.lenormand@inrae.fr)
Associated functions: extract_opportunities()
data(coords)
distance <- extract_distances(coords = coords,
method = "Haversine",
id = rownames(coords))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.