| Title: | Compute Distances along a Linear Shape |
|---|---|
| Description: | Computes distance between pair of points along a linear shape (e.g. a river, a road, etc.). This function uses parallel computing to speed up the distance computation. |
| Authors: | Nicolas Casajus [aut, cre, cph] (ORCID: <https://orcid.org/0000-0002-5537-5294>) |
| Maintainer: | Nicolas Casajus <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 1.0 |
| Built: | 2026-05-27 06:33:07 UTC |
| Source: | https://github.com/FRBCesab/snakedist |
Converts a data.frame to a distance matrix.
df_to_matrix(data, lower = TRUE, upper = TRUE, diag = TRUE, na_to_zero = TRUE)df_to_matrix(data, lower = TRUE, upper = TRUE, diag = TRUE, na_to_zero = TRUE)
data |
a |
lower |
a |
upper |
a |
diag |
a |
na_to_zero |
a |
A matrix of dimensions m x n, where m is the number of sites
(from) and n is the number of sites (to).
# Add an example ----# Add an example ----
Computes distance between two sites along a linear shape (e.g. a river, a road, etc.). This function uses parallel computing to speed up the distance computation.
distance_along( sites, along, density = 0.01, type = "regular", mc.cores = parallel::detectCores() - 1, ... )distance_along( sites, along, density = 0.01, type = "regular", mc.cores = parallel::detectCores() - 1, ... )
sites |
an |
along |
an |
density |
a |
type |
a |
mc.cores |
an |
... |
other argument to pass to |
A three-column data.frame with:
from, the first site
to, the second site
weight, the distance between the two sites along the linear shape
## Add an example ----## Add an example ----
Converts a (distance) matrix to a data.frame.
matrix_to_df(x, all = FALSE)matrix_to_df(x, all = FALSE)
x |
a |
all |
a |
A data.frame with the following three columns: from (the
first site), to (the second site) and distance (the value of the link
between two sites).
# Add an example ----# Add an example ----