R/create_river.R
create_river.Rd
This function creates a river network and individual river segment drainage basins from a digital elevation model. Outputs are written as gpkg files which can be directly used in hydrostreamer.
create_river( dem, minslope, threshold = 5, output_path = "", do_basins = TRUE, rsaga_env = FALSE, verbose = FALSE )
dem | A RasterLayer object in WGS84 coordinate system representing terrain elevation in raster values. |
---|---|
minslope | Minimum slope angle (degrees) to preserve between DEM cells when deriving river segments. Note that when using meters as vertical units and degrees as horizontal units the minimum slope calculation is not able to do the conversion. If the river network doesn't form, increase this parameter. Increasing minslope leads to more carefully carved flowpaths and decreasing it may result in flat areas due to elevation changes becoming less than the numerical accuracy of output layer. For further information, see SAGA-GIS tool ta_preprocessing module 4. |
threshold | Strahler order of small streams from which to start drawing rivers. Changes the threshold parameter in SAGA-GIS tool Channel Network and Drainage Basins (ta_channels module 5). If the river network comes out as too dense, increase the threshold and if it's too sparse, lower the threshold. |
output_path | Path to which the outputs will be written. Defaults to empty string; outputs will be written to temp folder. Value "wd" writes outputs to current working directory. |
do_basins | Whether delineating individual river segment basins or not. Basin delineation takes some extra time. |
rsaga_env | Valid RSAGA environment parameter list according to specifications in function rsaga.env(). Recommended not to give when automatic detection of RSAGA environment works. Even in manual case, best created by calling rsaga.env() with parameters. |
verbose | Whether outputting intermediate messages or not. |
Two-placed list of filenames to created rivers and basins. list$rivers gives path to created rivers and list$basins to created river segment basins. If list$basins is NA, no basins were created.
This package takes advantage of SAGA-GIS tools through RSAGA to first derive a river network and drainage directions and further to delineate individual river segment basins with hydrostreamer tools.
First, a DEM is read in and it is filled to ensure continuous flow paths throughout the given area into basin outlets instead of random sinks. SAGA-GIS ta_preprocessing module 4, which takes advantage of a sink fill algorithm by Wang & Liu (2006), is used in the filling.
After this, SAGA-GIS ta_channels module 5 is used to derive the river network and drainage directions throughout the area provided. Finally, drainage basins are delineated for each river segment.
Outputs are gpkg files which can be read and used directly in hydrostreamer. In return value, absolute file paths to resulting files are given as a list.
Vili Virkki
if (FALSE) { library(sf) library(hydrostreamer) library(raster) # Read in a DEM from an existing file dem <- raster("DEMraster.tif") # Create river network and drainage basins results <- create_river(dem = dem, minslope = 1.0) # Read from output files rivers_created <- st_read(results$rivers) basins_created <- st_read(results$basins) }