get_stream_network_interactively {gwavr}R Documentation

Get Stream Network Interactively

Description

This function allows the user to get stream networks and watersheds interactively with a shiny app. It uses the elevatr package to acquire the Digital Elevation Model (DEM) or user inputted DEM and whitebox package to delineate the stream network and watersheds (see details).

Usage

get_stream_network_interactively(
  map = NULL,
  ns = "streamnetwork-ui",
  viewer = shiny::paneViewer(),
  title = "Streamnetwork",
  dem = NULL,
  threshold = 1000,
  ...
)

Arguments

map

a background leaflet or mapview map to be used for editing. If NULL a blank mapview canvas will be provided.

ns

string name for the Shiny namespace to use. The ns is unlikely to require a change.

viewer

function for the viewer. See Shiny viewer. NOTE: when using browserViewer(browser = getOption("browser")) to open the app in the default browser, the browser window will automatically close when closing the app (by pressing "done" or "cancel") in most browsers. Firefox is an exception. See Details for instructions on how to enable this behaviour in Firefox.

title

string to customize the title of the UI window. The default is "Delineate Basin".

dem

A raster or terra object dem. (optional)

threshold

A threshold for stream initiation. 1000 (default).

...

other arguments to leafletOutput() in module and/or wbt_* functions.

Details

This function uses the package elevatr to download the DEM (unless you provide your own). Once the user has drawn the bounding box or inputed DEM and selected appropriate zoom (resolution) and threshold then the app will create basins and streams.

Steps

  1. Input a well-suited DEM zoom level and threshold. (skip if own DEM is inputted)

  2. Draw bounding box (rectangle or polygon) (skip if own DEM is inputted).

  3. Wait for layers to respond.

  4. Repeat steps 1-4 if needed.

  5. when finished, press 'done' and stream network and watersheds will be saved as a list in local environment with the associated flow accumulation and flow direction.

In addition, this function uses both whitebox::wbt_feature_preserving_smoothing() and whitebox::wbt_breach_depressions() prior to running the flow direction and flow accumulation (both d8) algorithms.

Value

A list of sf objects that the user collected during shiny session as well as flow accumulation and direction paths to tif. Each list will contain two sf objects: watersheds and streams. The streams object will also return these attributes: tribid, strahler, slope, length, mainstem, FID, STRM_VAL.

Note

If you add your own DEM then you don't need to draw a bounding box.

Examples


if(interactive()){
streamnetwork <- get_stream_network_interactively()
}




[Package gwavr version 0.3.1 Index]