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 |
|
viewer |
|
title |
|
dem |
A raster or terra object dem. (optional) |
threshold |
A threshold for stream initiation. 1000 (default). |
... |
other arguments to |
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
Input a well-suited DEM zoom level and threshold. (skip if own DEM is inputted)
Draw bounding box (rectangle or polygon) (skip if own DEM is inputted).
Wait for layers to respond.
Repeat steps 1-4 if needed.
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()
}