Skip to contents

Find and uniquely identify braids in a network of flowlines, given a dataframe containing comid, fromnode, tonode and divergence as columns. 'find_braids()" identifies braids as cycles in the graph representation of the river network.

Usage

find_braids(network, crosswalk_id = NULL, nested = TRUE, verbose = FALSE)

Arguments

network

The network object representing the river network.

crosswalk_id

unique ID column name

nested

Logical indicating whether the output dataframe should be nested, with each COMID having a list of all the braids it is a part of. If TRUE (Default), the braid_id column may contain multiple braid IDs for a given COMID. If FALSE, there may be duplicate COMIDs as a single COMID could be a part of multiple braids (braid_id)

verbose

Logical indicating whether to display verbose messages during the braid detection process.

Value

dataframe or sf dataframe with added braid_id

Examples

 if (FALSE) {
net <- nhdplusTools::navigate_network(
 start       = 101,
 mode        = "UT",
 distance_km = 100
 ) 
 
# drop most of the columns in the network dataset
net <- dplyr::select(net, comid, divergence, totdasqkm, fromnode, tonode, terminalpa)

# get a dataframe of COMIDs and braid IDs
braids <- find_braids(network = net, crosswalk_id = "comid")


# returns original data with each braid_id represented
# by its individual COMIDs (may contain duplicate COMIDs)
nested_braids = find_braids(network   = net,
                       crosswalk_id = "comid",
                       nested    = FALSE
                       )
}