Skip to contents

Determine how many different, unconnected/seperate sets of flowlines are within a set of NHDPlus flowlines. The input 'network' dataset must contain a comid, tonode, fromnode, and then (optionally) divergence and terminalpa attributes. Used internally within 'get_braid_list' and 'find_braids()' function to make sure each connected set of flowlines is addressed and braids are searched for in each seperated component.

Usage

find_connected_components(
  network,
  add = TRUE,
  arbitrary = TRUE,
  verbose = FALSE
)

Arguments

network

data.frame or sf object with comid, tonode, fromnode, and (optionally) divergence and terminalpa attributes. If a "tocomid" column exists, it is recommended to remove this beforehand

add

logical, whether to add the component_id to the original dataset. If TRUE (default) the original dataset is returned with an additional component_id column, indicating the set of connected components each comid belongs too. If FALSE, a dataframe with the COMID and component_id is returned

arbitrary

logical, whether use arbitrary numbering of components or to use starting COMID as component_id. If TRUE (default) components are given a component ID 1 through the number of components, otherwise (FALSE) an arbitrary COMID is used to as the component_id flag for all connected components

verbose

logical print status updates, if TRUE, messages will print. Default is FALSE.

Value

original dataframe with an added 'component_id' column (if add = TRUE) or a new dataframe with "comid" and "component_id" columns (if add = FALSE)