View source: R/aggregate_OCN.R
| aggregate_OCN | R Documentation |
Function that, given an OCN, builds the network at the river network (RN), aggregated (AG), subcatchment (SC), and catchment (CM) levels.
aggregate_OCN(OCN, thrA = 0.002 * OCN$FD$nNodes *
OCN$cellsize^2, streamOrderType = "Strahler", maxReachLength = Inf,
equalizeLengths = FALSE, breakpoints = NULL, displayUpdates = FALSE)
OCN |
A |
thrA |
Threshold value on drainage area used to derive the aggregated network. If |
streamOrderType |
If |
maxReachLength |
Maximum reach length allowed (in planar units). If the path length between a channel head and the downstream confluence
is higher than |
equalizeLengths |
Logical. Only effective when |
breakpoints |
Indices of additional nodes at the RN level that should be also nodes at the AG level (beyond source, confluence, outlet nodes
and AG nodes determined via |
displayUpdates |
Logical. State if updates are printed on the console while |
Note that each node (and the corresponding edge exiting from it, in the case of non-outlet nodes) at the AG level corresponds to
a subcatchment at the SC level that shares the same index: for instance, SC$toFD[i] contains all elements of
AG$toFD[i] (that is, the indices of pixels at FD level that constitute the edge departing from node i
are also part of subcatchment i).
A river object that contains all objects contained in OCN, in addition to the objects listed below.
New sublists RN, AG, SC, containing variables at the corresponding aggregation levels, are created.
Refer to section 4.2 of the vignette for a more detailed explanation on values OCN$XX$toYY, where XX and YY are two random aggregation levels.
FD$toRN |
Vector (of length |
FD$toSC |
Vector (of length |
RN$A |
Vector (of length |
RN$W |
Adjacency matrix ( |
RN$downNode |
Vector (of length |
RN$drainageDensity |
Drainage density of the river network, calculated as total length of the river network divided by area of the lattice. It is expressed in planar units^(-1). |
RN$leng |
Vector (of length |
RN$nNodes |
Number of nodes at the RN level. |
RN$nUpstream |
Vector (of length |
RN$outlet |
Vector (of length |
RN$Slope |
Vector (of length |
RN$toAG |
Vector (of length |
RN$toAGReach |
Vector (of length |
RN$toFD |
Vector (of length |
RN$toCM |
Vector (of length |
RN$upstream |
List (of length |
RN$X, RN$Y |
Vectors (of length |
RN$Z |
Vector (of length |
AG$A |
Vector (of length |
AG$AReach |
Vector (of length |
AG$W |
Adjacency matrix ( |
AG$downNode |
Vector (of length |
AG$leng |
Vector (of length |
AG$nNodes |
Number of nodes resulting from the aggregation process. |
AG$nUpstream |
Vector (of length |
AG$outlet |
Vector (of length |
AG$slope |
Vector (of length |
AG$streamOrder |
Vector (of length |
AG$upstream |
List (of length |
AG$toFD |
Vector of length |
AG$ReachToFD |
List (of length |
AG$toRN |
Vector of length |
AG$ReachToRN |
List (of length |
AG$toCM |
Vector (of length |
AG$X, AG$Y |
Vectors (of length |
AG$XReach, AG$YReach |
Vector (of length |
AG$Z |
Vector (of length |
AG$ZReach |
Vector (of length |
SC$ALocal |
Vector (of length |
SC$W |
Adjacency matrix ( |
SC$nNodes |
Number of subcatchments into which the lattice is partitioned. If |
SC$toFD |
List (of length |
SC$X, SC$Y |
Vectors (of length |
SC$Z |
Vector (of length |
Finally, thrA is added to the river object.
# 1a) aggregate a 20x20 OCN by imposing thrA = 4.
OCN <- aggregate_OCN(landscape_OCN(OCN_20), thrA = 4)
draw_thematic_OCN(OCN, drawNodes = TRUE)
# 1b) same as above, but identify all RN nodes as AG nodes
mrl <- 1.5*OCN_20$cellsize
OCN2 <- aggregate_OCN(landscape_OCN(OCN_20), thrA = 4, maxReachLength = mrl)
draw_thematic_OCN(OCN2, drawNodes = TRUE)
# 2) explore the effects of thrA, maxReachLength and equalizeLengths on a large OCN
OCN <- landscape_OCN(OCN_250_T) # it takes some seconds
OCN_a <- aggregate_OCN(OCN, thrA = 200) # it takes some seconds
OCN_b <- aggregate_OCN(OCN, thrA = 1000) # it takes some seconds
OCN_c <- aggregate_OCN(OCN, thrA = 1000, maxReachLength = 20) # it takes some seconds
OCN_d <- aggregate_OCN(OCN, thrA = 1000, maxReachLength = 20,
equalizeLengths = TRUE) # it takes some seconds
old.par <- par(no.readonly = TRUE)
par(mfrow = c(2,2))
draw_subcatchments_OCN(OCN_a)
points(OCN_a$AG$X, OCN_a$AG$Y, pch = 19, col = "#0044bb")
title(paste("No. AG nodes = ", as.character(OCN_a$AG$nNodes),
sep=""))
draw_subcatchments_OCN(OCN_b)
points(OCN_b$AG$X, OCN_b$AG$Y, pch = 19, col = "#0044bb")
title(paste("No. AG nodes = ", as.character(OCN_b$AG$nNodes),
sep=""))
draw_subcatchments_OCN(OCN_c)
points(OCN_c$AG$X, OCN_c$AG$Y, pch = 19, col = "#0044bb")
title(paste("No. AG nodes = ", as.character(OCN_c$AG$nNodes),
sep=""))
draw_subcatchments_OCN(OCN_d)
points(OCN_d$AG$X, OCN_d$AG$Y, pch = 19, col = "#0044bb")
title(paste("No. AG nodes = ", as.character(OCN_d$AG$nNodes),
sep=""))
par(old.par)
# note the difference between OCN_c and OCN_d at the bottom right corner of the lattice
# 3) use of breakpoints
OCN <- aggregate_OCN(landscape_OCN(OCN_20), thrA = 5)
draw_thematic_OCN(OCN, drawNodes=TRUE)
# add an AG node downstream of node 1 at AG level
new_node_RN <- OCN$RN$downNode[OCN$AG$toRN[1]]
OCN2 <- aggregate_OCN(landscape_OCN(OCN_20), thrA = 5, breakpoints = new_node_RN)
draw_thematic_OCN(OCN2, drawNodes = TRUE)
points(OCN$RN$X[new_node_RN], OCN$RN$Y[new_node_RN],
pch = 19, col = "red") # this node has been added
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.