BEACONs Hydrology R Functions

calc_dci() and calc_lwdci()

Dendritic connectivity index (DCI) describes the hydrologic connectedness of the stream network within an area. The Length-Weighted Dendritic Connectivity Index (lwDCI) builds on this concept by placing greater importance on the connectivity of the stream segments that are part of the same basin. While DCI treats all stream segments equally, lwDCI offers a more nuanced view by accounting for the relative importance of different parts of the network.

Values range between 0 and 1, with 1 indicating a completely connected river network.

Usage

calc_dci(
  conservation_area_sf,
  stream_sf = NULL,
  col_name = "network",
  buffer_width = 0.1
)

calc_lwdci(
  conservation_area_sf,
  stream_sf = NULL,
  col_name = "network",
  buffer_width = 0.1
)

Arguments

Both functions need the following:

  • CAs_sf: sf object of conservation areas in which to calculate DCI.

  • stream_sf: sf object of river network. Must have streams grouped in a BASIN attribute.

  • CAs_id: Column in CAs_sf specify unique identifier. Default is network.

  • buffer_width: (Optional) Width of buffer to apply to stream segments. Defaults to 0.1. Used to ensure adjacent stream segments are connected during analysis.

📤 Output

A vector of numeric DCI or lwDCI values matching the input features.

Details

Developed by Cote et al. (2009), the Dendritic Connectivity Index quantifies “longitudinal connectivity of river networks based on the expected probability of an organism being able to move freely between two random points of the network.” Longitudinal connectivity refers to connections between upstream and downstream sections of the network. The index is calculated as

DCI formula

where li is the length of a stream (or river) section and L is the total length of the stream network within the benchmark. The index ranges from 0 (low longitudinal connectivity) to 1 (high longitudinal connectivity).

If the conservation areas overlap two ocean drainage, the use of calc_lwdci() is more suitable.

Examples

Running the examples

The example below allow to estimate dci and lwdci for a set of conservation areas. Because the two functions returns a vector of index, the script calculate the respective indexes and integrate the results in the reserves object prior to save it as a new shapefile.

  1. Download and unzip BEACONs R Tools

  2. Run the examples below.

# Load libraries
library(sf)
library(dplyr)

# Set working directory
setwd("your/path/to/downloads/folder")

source("./R/hydrology.R")

# --------------------------------------
# SET PARAMS  --------------------
# --------------------------------------
dirpath <- getwd()

#Set access path 
reserves <- file.path(dirpath, "data/reserves_sample.shp")
streams <- file.path(dirpath, "data/streams_sample.shp")

colName <- "reserve"

#Create output folder
out_dir <- file.path(dirpath, "shp_output")
if(!dir.exists(out_dir)){
  dir.create(out_dir)
}

# Set if DCI and LWDCI should be added
addDCI <- TRUE
addLWDCI <- TRUE



# --------------------------------------
#--RUN
# --------------------------------------
# Initialize sf objects
reserves_sf <- st_read(reserves)
streams_sf <- st_read(streams)

if(addDCI){
  reserves_sf <- reserves_sf %>%
  mutate(dci = sapply(1:nrow(reserves_sf), function(i) {
    i <- reserves_sf[i, ]
    calc_dci(i, streams_sf, CAs_id = colName) 
  }))
}
if(addLWDCI){
  reserves_sf <- reserves_sf %>%
  mutate(lwdci = sapply(1:nrow(reserves_sf), function(j) {
    j <- reserves_sf[j, ]
    calc_lwdci(j, streams_sf, CAs_id = colName) 
  }))
}

#Save results
write_sf(reserves_sf, dsn=file.path(out_dir, "reserves_dci.shp"), append = FALSE)