buildsegroutes {riverdist}R Documentation

Build Segment Routes

Description

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.

Usage

buildsegroutes(rivers, lookup = NULL, verbose = FALSE)

Arguments

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 TRUE or FALSE, and defaults to NULL. If the default value is accepted, lookup tables will be built if the river network has 400 segments or fewer.

verbose

Whether or not to print the segment number the function is currently building a route for (used for error checking). Defaults to FALSE.

Value

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.)

Note

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.

Author(s)

Matt Tyers

Examples

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)
Sys.time() - tstart

# after
tstart <- Sys.time()
detectroute(start=120, end=111, rivers=abstreams)
Sys.time() - tstart

[Package riverdist version 0.16.3 Index]