Calculates river network distances as +/-, defined as upriver/downriver.
Specifying net=TRUE
will compute net upriver distance (3 river km
down a tributary and then 15 river km up the mainstem will mean 12 rkm net.
Otherwise the function will return 18 rkm upriver travel.)
The mouth (lowest point) segment and vertex must be specified (see setmouth).
upstream(startseg, endseg, startvert, endvert, rivers, flowconnected = FALSE, net = FALSE, stopiferror = TRUE, algorithm = NULL)
startseg | Segment number of the start of the route |
---|---|
endseg | Segment number of the end of the route |
startvert | Vertex number of the start of the route |
endvert | Vertex number of the end of the route |
rivers | The river network object to use |
flowconnected | If |
net | Whether to calculate net distance ( |
stopiferror | Whether or not to exit with an error if a route cannot be
found. If this is set to |
algorithm | Which route detection algorithm to use ( |
Upstream distance (numeric). Returns NA if flowconnected
has value TRUE
and the two segments are not flow-connected.
Building routes from the river mouth to each river network segment and/or distance lookup tables will greatly reduce computation time (see buildsegroutes).
data(Gulk) # Mouth must be specified Gulk$mouth$mouth.seg <- 1 Gulk$mouth$mouth.vert <- 1 plot(x=Gulk)upstream(startseg=6, endseg=4, startvert=140, endvert=40, rivers=Gulk, net=TRUE)#> [1] -35553.56upstream(startseg=6, endseg=4, startvert=140, endvert=40, rivers=Gulk, net=FALSE)#> [1] -41878.12upstream(startseg=6, endseg=4, startvert=140, endvert=40, rivers=Gulk, flowconnected=TRUE)#> [1] NA