Utility function that takes the output from 'find_braids(nested = TRUE)' and unpacks/unnests braid_id column
unpack_braids.Rd
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'.
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
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)
}