Learn R Programming

riverdist (version 0.17.0)

buildsegroutes: 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)

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

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.

Author

Matt Tyers

Examples

Run this code
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

Run the code above in your browser using DataLab