Trim channel objects to those draining to named outlets

trim_channel(chn, outlets, removed = FALSE)

Arguments

chn

the channel object

outlets

names of the outlets to consider

removed

should the removed objects be returned

Details

Starting with the named outlet objects the channel network is passed up using the connectivity given by the start and end node, only those flaged as connected are returned.

Examples

chnFile <- system.file("extdata", "gis", "SwindaleRiverNetwork.gpkg",
                       package="dynatop", mustWork = TRUE)
chn <- terra::vect(chnFile)
chn$slope <- 1e-3
chn$class <- 1
chn$width <- 1
chn$depth <- 0.1
chn <- convert_channel(chn,
                       property_names=c(uid = "identifier",
                                        startNode = "startNode",
                                        endNode = "endNode",
                                        slope = "slope",
                                        class = "class",
                                        width="width",
                                        depth="depth"))
tchn <- trim_channel(chn,chn$uid[1])
nrow(chn)
#> [1] 19
nrow(tchn)
#> [1] 1