calc_edges: Calculate edges for SSN object.

View source: R/calc_edges.R

calc_edgesR Documentation

Calculate edges for SSN object.

Description

A vector (lines) map 'edges' is derived from 'streams_v' and several attributes are assigned.

Usage

calc_edges()

Details

Steps include:

  • Assign unique 'rid' to each stream segment

  • Find different stream networks in the region and assign 'netID'

  • Calculate segments upstream distance, 'upDist' = flow length from the upstream node of the stream segment to the outlet of the network

  • Calculate reach contributing areas (RCA ) per segment, 'rcaArea' = subcatchment area of each segment in square km

  • Calculate catchment areas, 'H2OArea' = total catchment area of each segment in square km

All lengths are rounded to 2 and all areas to 6 decimal places, respectively.

Value

Nothing. The function produces the following map:

  • 'edges': derived stream segments with computed attributes needed for 'SSN' (vector)

Note

setup_grass_environment, import_data and derive_streams must be run before.

Author(s)

Mira Kattwinkel, mira.kattwinkel@gmx.net, Eduard Szoecs, eduardszoecs@gmail.com

Examples


# Initiate and setup GRASS
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS")
if(.Platform$OS.type == "windows"){
  grass_program_path = "c:/Program Files/GRASS GIS 7.6"
  } else {
  grass_program_path = "/usr/lib/grass78/"
  }

setup_grass_environment(dem = dem_path, 
                        gisBase = grass_program_path,      
                        remove_GISRC = TRUE,
                        override = TRUE
                        )
gmeta()
                        
# 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")                  
import_data(dem = dem_path, sites = sites_path)

# Derive streams from DEM
derive_streams(burn = 0, accum_threshold = 700, condition = TRUE, clean = TRUE)

check_compl_confluences()

# Prepare edges
calc_edges()

# Plot data
library(sp)
dem <- readRAST('dem', ignore.stderr = TRUE, plugin = FALSE)
edges <- readVECT('edges', ignore.stderr = TRUE)
plot(dem, col = terrain.colors(20))
lines(edges, col = 'blue')



MiKatt/openSTARS documentation built on June 17, 2022, 5:08 a.m.