distance_euclidean {chessboard} | R Documentation |
Compute the pairwise Euclidean distance
Description
Computes the Euclidean distance between two nodes using the function
sf::st_distance()
. If the CRS is not a Cartesian system, the Great Circle
distance will be used instead.
Usage
distance_euclidean(sites, ...)
Arguments
sites |
an |
... |
other argument to pass to |
Value
A three-column data.frame
with:
-
from
, the first node -
to
, the second node -
weight
, the Euclidean distance between the two nodes
Examples
# Import Adour sites ----
path_to_file <- system.file("extdata", "adour_survey_sampling.csv",
package = "chessboard")
adour_sites <- read.csv(path_to_file)
# Select the 15 first sites ----
adour_sites <- adour_sites[1:15, ]
# Create node labels ----
adour_sites <- create_node_labels(adour_sites,
location = "location",
transect = "transect",
quadrat = "quadrat")
# Convert sites to sf object (POINTS) ----
adour_sites <- sf::st_as_sf(adour_sites, coords = c("longitude", "latitude"),
crs = "epsg:2154")
# Compute distances between pairs of sites ----
weights <- distance_euclidean(adour_sites)
head(weights)
[Package chessboard version 0.1 Index]