paths_OCN | R Documentation |
Function that determines upstream and downstream paths and path lengths between any nodes of the network at the aggregated level.
paths_OCN(OCN, level = c("RN","AG"), whichNodes = NULL, includePaths = FALSE,
includeDownstreamNode = FALSE, includeUnconnectedPaths = FALSE, displayUpdates = FALSE)
OCN |
A |
level |
Character vector. At which level should paths be calculated? Possible values are |
whichNodes |
List. It allows specifying a subset of nodes for which paths are computed. In the case of large rivers, this could
speed up the function execution substantially. It must contain objects named |
includePaths |
Logical. If |
includeDownstreamNode |
Logical. If |
includeUnconnectedPaths |
Logical. If |
displayUpdates |
Logical. State if updates are printed on the console while |
A river
object that contains all objects contained in OCN
, in addition to the objects listed below.
RN$downstreamPath |
List (of length |
RN$downstreamPathLength |
Sparse matrix ( |
RN$downstreamLengthUnconnected |
Matrix ( |
AG$downstreamPath |
List (of length |
AG$downstreamPathLength |
Sparse matrix ( |
AG$downstreamLengthUnconnected |
Matrix ( |
# 1) Calculate paths between nodes of an OCN
OCN <- paths_OCN(aggregate_OCN(landscape_OCN(OCN_20), thrA = 4))
# 2) Display distance to outlet (at the RN level) along the main stem
# of an OCN
OCN <- aggregate_OCN(landscape_OCN(OCN_250_T)) # this takes some seconds
OCN <- paths_OCN(OCN, includePaths = TRUE) # this takes some seconds
distanceToOutlet <- OCN$RN$downstreamPathLength[,OCN$RN$outlet]
farthestNode <- which(distanceToOutlet == max(distanceToOutlet))
mainStem <- OCN$RN$downstreamPath[[farthestNode]][[OCN$RN$outlet]]
theme <- rep(NaN, OCN$RN$nNodes)
theme[mainStem] <- distanceToOutlet[mainStem]
draw_thematic_OCN(theme, OCN)
title("Distance to outlet along the main stem [pixel units]")
# 3) use whichNodes to compute distance between two non flow-connected nodes
OCN <- aggregate_OCN(landscape_OCN(OCN_250_T)) # this takes some seconds
RNnodes <- c(483, 516)
plot(OCN)
points(OCN$RN$X[RNnodes], OCN$RN$Y[RNnodes], pch = 19) # nodes 483 and 516 are not flow-connected
OCN <- paths_OCN(OCN, whichNodes = list(RN=RNnodes), includePaths = TRUE,
includeUnconnectedPaths = TRUE)
OCN$RN$downstreamPath[[RNnodes[1]]][[OCN$RN$outlet]]
# the outlet node has been added to whichNodes$RN
OCN$RN$downstreamLengthUnconnected[RNnodes[1], RNnodes[2]]
# distance from node 1 to the common downstream confluence
OCN$RN$downstreamLengthUnconnected[RNnodes[2], RNnodes[1]]
# distance from node 2 to the common downstream confluence
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.