d_index_calculation: Calculate Reach- and Catchment-scale index improvement for...

View source: R/d_index_calculation.R

d_index_calculationR Documentation

Calculate Reach- and Catchment-scale index improvement for scenarios of barriers removal

Description

Calculate Reach- and Catchment-scale index improvement for scenarios of barriers removal

Usage

d_index_calculation(
  graph,
  ...,
  barriers_metadata,
  id_barrier = "id_barrier",
  pass_u_updated = "pass_u_updated",
  pass_d_updated = "pass_d_updated",
  mode = "leave_one_out",
  parallel = TRUE,
  ncores
)

Arguments

graph

an object of class 'igraph'. Can be both directed or undirected.

...

other arguments passed to the function 'index_calculation'

barriers_metadata

data.frame that must contain a column having the same name as the 'id_barrier' attribute of the graph, and two columns with the corresponding upstream and downstream improved passabilities (see 'pass_u_updated' and 'pass_d_updated' parameters).

id_barrier

graph edges attribute used to label barriers. Default is "id_barrier". Must be of type charachter.

pass_u_updated

field in barrier_metadata where updated value for upstream passability is stored (recommended values higher than the original passability).

pass_d_updated

field in barrier_metadata where updated value for downstream passability is stored (recommended values higher than the original passability).

mode

currentlym only "leave_one_out" is implemented.

parallel

logical value to flag if parallel option is to be used.

ncores

define how many cores are used in parallel processing. Active only when parallel = TRUE

Details

Setting c_ij_flag = FALSE (see index_calculation arguments) removes from the calculations the effect of barriers, i.e. the c_ij contribution is not used in the calculation of the index. Setting B_ij_flag = FALSE (see index_calculation arguments) removes from the calculations the effect of movement/dispersal, i.e. the B_ij contribution is not used in the calculation of the index. Note that it is not possible to set both c_ij_flag = FALSE and B_ij_flag = FALSE.

The setting dir_distance_type = "symmetric" (see index_calculation arguments) is to be used when the directionality of the river network is not relevant. The distance between reaches midpoints is calculated for each couple of reaches. The setting dir_distance_type = "asymmetric" (see index_calculation arguments) is to be used when the directionality is relevant. The distance between reaches midpoints is calculated for each couple of reaches and splitted between 'upstream travelled' distance and 'downstream travelled' distance

The 'param_u', 'param_d', and 'param' values are interpreted differently based on the formula used to relate distance and probability. When disp_type ="exponential" (see index_calculation arguments), those values are used as the base of the exponential dispersal kernel: B_ij = param^d_ij. When disp_type ="threshold" (see index_calculation arguments), those values are used to define the maximum dispersal length: B_ij = ifelse(d_ij < param, 1, 0).

Value

returns a data.frame containing the percent improvement of the index for each barrier present in the 'barriers_metadata' variable. If index_type = "full" (see index_calculation arguments), the data.frame is organized by 'id_barrier'. If index_type = "reach" (see index_calculation arguments), the data.frame is organized by 'id_barrier' and 'name'. In both cases, both numerator and denominator used in the index calculations are reported in the columns 'num' and 'den'. The column 'd_index' contains the relative index improvement when each barrier is removed.

References

Baldan, D., Cunillera-Montcusí, D., Funk, A., & Hein, T. (2022). Introducing ‘riverconn’: an R package to assess river connectivity indices. Environmental Modelling & Software, 156, 105470.

Examples

library(igraph)
library(igraph)
g <- igraph::graph_from_literal(1-+2, 2-+4, 3-+2, 4-+6, 6-+7, 5-+6, 7-+8, 9-+5, 10-+5 )
E(g)$id_dam <- c(NA, NA, "1", NA, NA, "2", NA, NA, NA)
E(g)$type <- ifelse(is.na(E(g)$id_dam), "joint", "dam")
V(g)$length <- c(1, 1, 2, 3, 4, 1, 5, 1, 2, 1)
V(g)$Id <- V(g)$name
E(g)$pass_u <- E(g)$pass_d <- ifelse(!is.na(E(g)$id_dam),0.1,NA)
dams_metadata <- data.frame("id_dam" =  c("1", "2"),
"pass_u_updated" = c(1, 1), "pass_d_updated" = c(1, 1))
d_index <- d_index_calculation(g, barriers_metadata = dams_metadata,
id_barrier = "id_dam", parallel = FALSE, param = 0.6)



riverconn documentation built on May 31, 2023, 8:02 p.m.