updist_edges {SSNbler} | R Documentation |
Get upstream distance for edges in a Landscape Network (LSN)
Description
Calculate the distance from the stream outlet (i.e. the most downstream location on the stream network) to the upstream node of each edge feature (i.e. upstream distance) in the Landscape Network (LSN)
Usage
updist_edges(
edges,
lsn_path = NULL,
calc_length = FALSE,
length_col = NULL,
save_local = TRUE,
overwrite = TRUE,
verbose = TRUE
)
Arguments
edges |
An |
lsn_path |
Local pathname to a directory in character format
specifying where relationships.csv resides, which is created
using |
calc_length |
A logical indicating whether a column
representing line length should be calculated and added to
|
length_col |
Optional. If |
save_local |
Logical indicating whether the updated
|
overwrite |
A logical indicating whether results should be
overwritten if the upDist column already exists in |
verbose |
Logical. Indicates whether messages about the
function progress should be printed to the console. Defaults to
|
Details
updist_edges()
calculates the total hydrologic distance from
the uppermost location on each edge feature (upstream node) to
the stream outlet (i.e. the most downstream location in the
stream network), when movement is restricted to the stream
network. We refer to this as the upstream distance. Upstream distances are
measured in the map projection units for the sf
object edges and stored in
a new column in edges named upDist
.
The upstream distances stored in upDist
are used to calculate the upstream distance for
sites in updist_sites()
and the pairwise hydrologic distances used to fit spatial stream network models in
the 'SSN2' package. Do not modify the name of the column in any way or the values the upDist
column contains.
Value
An sf
object representing edges in the LSN, with a new upDist
column. When calc_length = TRUE
an additional column named length_col
Examples
# Get temporary directory, where the example LSN will be stored
# locally.
temp_dir <- tempdir()
# Build the LSN. When working with your own data, lsn_path will be
# a local folder of your choice rather than a temporary directory.
edges<- lines_to_lsn(
streams = MF_streams,
lsn_path = temp_dir,
snap_tolerance = 1,
check_topology = FALSE,
overwrite = TRUE,
verbose = FALSE
)
# Calculate upstream distance for edges
edges<- updist_edges(
edges = edges,
lsn_path = temp_dir,
calc_length = TRUE,
length_col = "Length",
overwrite = TRUE,
save_local = FALSE,
verbose = FALSE
)
# Notice that two new columns have been added to edges containing
# line feature length (Length) and the upstream distance (upDist)
names(edges)
summary(edges[,c("Length", "upDist")])