R/distance_along.R
distance_along.Rd
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,
...
)
an sf
object of type POINT
. A spatial object containing
coordinates of sites. Note that the first column must be the
site identifier.
an sf
object of type LINESTRING
. A spatial object
containing coordinates of the linear shape (e.g. a river, a road, etc.)
to follow while computing distances between the two sites.
a numeric
of length 1. The density of points to sample on
the linear structure. See sf::st_line_sample()
for further detail.
Default is 1/100
.
a character
of length 1. The method to sample points on the
linear shape. Either regular
(default) or random
.
an integer
of length 1. The number of cores to use
(must be lesser than the number of cores available on the machine obtained
with parallel::detectCores()
).
other argument to pass to sf::st_line_sample()
.
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 ----