openSTARS (version 1.0.0)

derive_streams: Derive stream network from DEM.

Description

Streams are derived from a digital elevation model (DEM) using r.stream.extract. If a stream network is available (see import_data) and burn > 0 it will be first burnt into the digital elevation model (DEM). Stream topology is derived using r.stream.order.

Usage

derive_streams(burn = 5, accum_threshold = 700, condition = TRUE,
  min_stream_length = 0, dem_name = NULL, clean = TRUE, mem = FALSE)

Arguments

burn

numeric; how many meters should the streams be burned into the DEM?

accum_threshold

integer; accumulation threshold to use (i.e. minimum flow accumulation value in cells that will initiate a new stream).

condition

logical; should the DEM be conditioned using r.hydrodem?#'

min_stream_length

integer: minimum stream length in number of DEM raster cells; shorter first order stream segments are deleted; default: 0

dem_name

character vector, optional; default: 'dem'; useful if conditioned and / or burnt in DEM raster from previous runs shall be used.

clean

logical; should intermediate raster layer of imported streams ('streams_or') be removed from 'GRASS' session?

mem

logical; should -m flag in GRASS r.watershed be used (as indicated in its help) see also watershed_memory-function

Value

Nothing. The function produces the following maps:

  • 'streams_r' derived streams (raster)

  • 'streams_v' derived streams with topology (vector)

  • 'dirs' flow directions (raster)

  • 'accums' accumulation values (raster)

  • 'dem_cond' conditioned dem (raster) if condition is TRUE

  • 'dem_[cond]_burn[X]' burnt in DEM (raster) if burn is > 0

The original GRASS map 'dem' is not modified if condition is TRUE and / or burn > 0.

Details

For details on accum_threshold and min_stream_length see the parameters 'threshold' and 'stream_length' at r.stream.extract. It might be useful to not burn in the whole available stream network but only parts of it (e.g., larger streams with higher Strahler stream order only). For this, the stream network needs to be pre-processed before loading it with import_data.

Examples

Run this code
# NOT RUN {
# Initiate GRASS session
if(.Platform$OS.type == "windows"){
  gisbase = "c:/Program Files/GRASS GIS 7.2.0"
  } else {
  gisbase = "/usr/lib/grass72/"
  }
initGRASS(gisBase = gisbase,
    home = tempdir(),
    override = TRUE)

# Load files into GRASS
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS")
sites_path <- system.file("extdata", "nc", "sites_nc.shp", package = "openSTARS")
setup_grass_environment(dem = dem_path, sites = sites_path)
import_data(dem = dem_path, sites = sites_path)
gmeta()

# Derive streams from DEM
derive_streams(burn = 0, accum_threshold = 700, condition = TRUE, clean = TRUE)
dem <- readRAST('dem', ignore.stderr = TRUE)
sites <- readVECT('sites_o', ignore.stderr = TRUE)
streams <- readVECT('streams_v', ignore.stderr = TRUE)
plot(dem, col = terrain.colors(20))
lines(streams, col = 'blue', lwd = 2)
points(sites, pch = 4)
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace