Skip to contents

Unnests the comma separated braid_id column into individual rows for each braid ID/crosswalk_id pairing. This function will unnest the nested braid_ids column that is the output of calling 'find_braids()' with 'nested = TRUE', essentially giving the output of running 'nested = FALSE'.

Usage

unpack_braids(x, crosswalk_id = NULL, into_list = FALSE)

Arguments

x

dataframe or sf dataframe containing a "comid" and "braid_id" column

crosswalk_id

unique ID column name

into_list

logical, if TRUE, unpacked braid_ids and corresponding crosswalk_ids are returned as a list. Default is FALSE

Value

dataframe or list

Examples

 if (FALSE) {
# get a NHDPlus flowlines network
net <- nhdplusTools::navigate_network(start = 101, mode = "UT", distance_km = 100)

# Drop some columns for clarity
net <- dplyr::select(net, comid, divergence, fromnode, tonode)

# locate braids in the network and specify nested braid_id return
braids <- find_braids(net, add = TRUE, nested = TRUE)

# unnest the nested braid_id column (explode the list column into individual rows)
unpacked <- unpack_braids(braids)
}