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 sf object of type POINT. A spatial object containing coordinates of sites. Note that the first column must be the node label created by the function create_node_labels().

...

other argument to pass to sf::st_distance().

Value

A three-column data.frame with:

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]