Adds the travel routes from the mouth (lowest point) of a river network to each segment, and (optionally) distance lookup tables. This greatly reduces the time needed to detect routes, making distance calculation much more efficient, particularly in the case of multiple distance calculations.
buildsegroutes(rivers, lookup = NULL, verbose = FALSE)
rivers | The river network object to use |
---|---|
lookup | Whether to build lookup tables as well. This may take
some time, but will result in even faster distance computation in analyses
(see buildlookup). Because of the object size returned, this may
not be advisable in a large river network (more than a few hundred
segments). Accepts |
verbose | Whether or not to print the segment number the function is currently building a route for (used for error checking). Defaults to FALSE. |
A rivernetwork object, with a new list element, $segroutes
,
which gives the route from the mouth to each rivernetwork segment.
Optionally, it may add $distlookup
, distance lookup tables for even
faster distance computation. (See rivernetwork.)
In the event of braiding (multiple channels), it is likely that there will be differences in the routes detected. If this is the case, building routes will likely result in a shorter and more efficient route. Regardless, extreme caution is always advised in the event of braiding.
The mouth segment and vertex must be specified (see setmouth).
This function is called within cleanup, which is recommended in most cases.
data(abstreams) plot(x=abstreams)abstreams1 <- abstreams abstreams1$segroutes <- NULL #taking out the $segroutes component # before tstart <- Sys.time() detectroute(start=120, end=111, rivers=abstreams1)#> [1] 120 103 106 109 112 116 124 132 134 133 135 142 153 152 144 136 127 115 114 #> [20] 107 108 111Sys.time() - tstart#> Time difference of 0.01074767 secs#> [1] 120 103 106 109 112 116 124 132 134 133 135 142 153 152 144 136 127 115 114 #> [20] 107 108 111Sys.time() - tstart#> Time difference of 0.004034281 secs