Returns a matrix of upstream distance between every point and every other point of given river locations (segment and vertex), or of a subset. The mouth (lowest point) segment and vertex must be specified (see setmouth).

upstreammat(seg, vert, rivers, logical = NULL, ID = NULL,
  flowconnected = FALSE, net = FALSE, stopiferror = TRUE,
  algorithm = NULL)

Arguments

seg

A vector of river locations (segment component).

vert

A vector of river locations (vertex component).

rivers

The river network object to use.

logical

A boolean vector that can be used for subsetting - if used, riverdirectionseq() will only return pairwise distances in which a specified condition is met.

ID

a vector of observation IDs for aid in interpreting the output table

flowconnected

If TRUE, only returns distance if the input segments are flow-connected. Defaults to FALSE.

net

Whether to calculate net upstream distance (net=TRUE) or total distance (net=FALSE, default). See upstream.

stopiferror

Whether or not to exit with an error if a route cannot be found. If this is set to FALSE and a route cannot be found, the function will return NA in the appropriate entry. Defaults to TRUE. See detectroute.

algorithm

Which route detection algorithm to use ("Dijkstra", "sequential", or "segroutes"). If left as NULL (the default), the function will automatically make a selection. See detectroute for more details.

Value

A matrix of upstream distances (numeric) with rows and columns labeled by corresponding values of ID. See upstream for additional information.

Note

Building routes from the river mouth to each river network segment and/or distance lookup tables will greatly reduce computation time (see buildsegroutes).

See also

upstream

Examples

data(Gulk, fakefish) # Mouth must be specified Gulk$mouth$mouth.seg <- 1 Gulk$mouth$mouth.vert <- 1 logi1 <- (fakefish$flight.date==as.Date("2015-11-25")) upstreammat(seg=fakefish$seg, vert=fakefish$vert, rivers=Gulk, logical=logi1)
#> 91 92 93 94 95 96 #> 91 0.000 114024.928 120991.401 47578.972 5331.438 98550.78 #> 92 -114024.928 0.000 6966.473 -66445.955 -108693.489 -15474.15 #> 93 -120991.401 -6966.473 0.000 -73412.429 -115659.963 -22440.63 #> 94 -47578.972 66445.955 73412.429 0.000 -42247.534 50971.80 #> 95 -5331.438 108693.489 115659.963 42247.534 0.000 93219.34 #> 96 -98550.776 15474.152 22440.625 -50971.803 -93219.337 0.00 #> 97 -56658.868 57366.060 64332.533 -9079.896 -51327.430 41891.91 #> 98 -89172.366 24852.562 31819.035 -41593.393 -83840.928 9378.41 #> 99 3836.327 117861.255 124827.728 51415.300 9167.765 102387.10 #> 100 -55326.842 58698.086 65664.559 -7747.869 -49995.403 43223.93 #> 97 98 99 100 #> 91 56658.868 89172.37 -3836.327 55326.842 #> 92 -57366.060 -24852.56 -117861.255 -58698.086 #> 93 -64332.533 -31819.04 -124827.728 -65664.559 #> 94 9079.896 41593.39 -51415.300 7747.869 #> 95 51327.430 83840.93 -9167.765 49995.403 #> 96 -41891.908 -9378.41 -102387.103 -43223.934 #> 97 0.000 32513.50 -60495.195 -1332.026 #> 98 -32513.498 0.00 -93008.693 -33845.524 #> 99 60495.195 93008.69 0.000 59163.169 #> 100 1332.026 33845.52 -59163.169 0.000