diff --git a/workspace/00_enhd_nwm_network.Rmd b/workspace/00_enhd_nwm_network.Rmd index de77a8bb22490eae6c124874d75b5a7547a4b571..a7450cd34e509c5202e37c40e4441b716fc3f9a4 100644 --- a/workspace/00_enhd_nwm_network.Rmd +++ b/workspace/00_enhd_nwm_network.Rmd @@ -49,10 +49,6 @@ RNetCDF::close.nc(nwm_nc) nhd_net <- nhdplusTools::get_vaa() -degen_networks <- nhd_net[nhd_net$totdasqkm == 0 & nhd_net$terminalfl == 1, ]$terminalpa - -nhd_net <- filter(nhd_net, !terminalpa %in% degen_networks) - names(nhd_net) <- tolower(names(nhd_net)) names(enhd) <- tolower(names(enhd)) diff --git a/workspace/01_NHD_prep.Rmd b/workspace/01_NHD_prep.Rmd index 790460e0b94e7a223da17fc38453de115544dd4c..1f977dd5338bfe315652b9d3c2934a627d934435 100644 --- a/workspace/01_NHD_prep.Rmd +++ b/workspace/01_NHD_prep.Rmd @@ -44,6 +44,18 @@ fline <- sf::st_cast(fline, "LINESTRING") catchment <- sf::read_sf(file.path(data_paths$nhdplus_dir, "reference_catchments.gpkg")) +# we can remove truely degenerate COMIDs +# for 0 upstream area and no catchment area +degen_comid <- fline[fline$TotDASqKM == 0 & + !fline$COMID %in% catchment$featureid, ]$COMID + +# need to make sure we don't disconnect anything. +keep_tocomid <- fline$toCOMID[!fline$COMID %in% degen_comid] + +if(length(degen_comid[degen_comid %in% keep_tocomid]) > 0) stop("this will break the network") + +fline <- fline[!fline$COMID %in% degen_comid, ] + for(VPU in vpu_codes) { rm(rpu_code)