calc_binary: Calculate binary IDs for each stream network.

Description Usage Value Note Author(s) Examples

View source: R/export_ssn.R View source: R/calc_binary.R

Description

Calculate binary IDs for each stream network built up by '0' and '1'. This function is called by export_ssn and there is no need for it be called by the users.

Calculate binary IDs for each stream network built up by '0' and '1'. This function is called by export_ssn and there is no need for it be called by the users.

Usage

1
2
3

Value

A list with one slot for each network id containing a data frame with 'rid' and 'binaryID' for each segment belonging to this network.

A list with one slot for each network id containing a data frame with 'rid' and 'binaryID' for each segment belonging to this network.

Note

import_data, derive_streams, calc_edges and calc_sites must be run before.

import_data, derive_streams, calc_edges and calc_sites must be run before.

Author(s)

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

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

@export

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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")
streams_path <- system.file("extdata", "nc", "streams.shp", package = "openSTARS")
preds_v_path <- system.file("extdata", "nc", "pointsources.shp", package = "openSTARS")
preds_r_path <- system.file("extdata", "nc", "landuse_r.tif", package = "openSTARS")
                 
import_data(dem = dem_path, sites = sites_path, streams = streams_path,
            predictor_vector = preds_v_path, predictor_raster = preds_r_path)

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

# Check and correct complex confluences (there are no complex confluences in this
# example date set; set accum_threshold in derive_streams to a smaller value
# to create complex confluences)
cj <- check_compl_confluences()
if(cj){
  correct_compl_confluences()
}

# Prepare edges
calc_edges()

# Prepare site
calc_sites()

binaries <- calc_binary()
head(binaries[[1]])

openSTARS documentation built on Feb. 4, 2022, 5:08 p.m.