detectroute {riverdist}R Documentation

Detect Route

Description

Called internally within riverdistance. Detects the sequential route from one river network segment to another.

Usage

detectroute(
  start,
  end,
  rivers,
  verbose = FALSE,
  stopiferror = TRUE,
  algorithm = NULL
)

Arguments

start

Segment number of the start of the route

end

Segment number of the end of the route

rivers

The river network object to use

verbose

Whether or not to print all routes being considered (used for error checking). Defaults to FALSE.

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, detectroute() will return NA. Defaults to TRUE.

algorithm

Which route detection algorithm to use. If set to NULL (the default), the function will automatically make a selection. Choices are:

  • Setting algorithm="sequential" will be quite slow, and may give inaccurate results in the event of braiding. This algorithm returns the first complete route detected, which may not be the shortest. This algorithm is not recommended in almost all cases, but is retained as an option for certain checks. It will not be used unless specified.

  • Setting algorithm="Dijkstra" will be much faster, and will return the shortest route in the event of braiding. If braiding is present or unknown, this will be the algorithm automatically chosen.

  • Setting algorithm="segroutes" will be the fastest of all, but will only return results in a non-braided network. This will be the algorithm automatically selected if segment routes are present - see buildsegroutes.

Value

A vector of segment numbers corresponding to the ordered route.

Author(s)

Matt Tyers

Examples

data(Gulk)
plot(x=Gulk, cex=1)

detectroute(start=6, end=14, rivers=Gulk)

tstart <- Sys.time()
detectroute(start=120, end=111, rivers=abstreams, algorithm="sequential")
tend <- Sys.time()
tend - tstart

data(abstreams)
tstart <- Sys.time()
detectroute(start=120, end=111, rivers=abstreams, algorithm="Dijkstra")
tend <- Sys.time()
tend - tstart

tstart <- Sys.time()
detectroute(start=120, end=111, rivers=abstreams, algorithm="segroutes")
tend <- Sys.time()
tend - tstart

[Package riverdist version 0.16.3 Index]