Skip to content
Snippets Groups Projects
Commit 8b7cd770 authored by Blodgett, David L.'s avatar Blodgett, David L.
Browse files

Merge branch 'main' into 'main'

WB inlet and Outlet fix

See merge request !155
parents 55880515 3d246372
No related branches found
No related tags found
1 merge request!155WB inlet and Outlet fix
...@@ -209,7 +209,8 @@ if(all(is.na(tmp_POIs$Type_WBOut))) { ...@@ -209,7 +209,8 @@ if(all(is.na(tmp_POIs$Type_WBOut))) {
# Waterbody list that strictly meet the size criteria # Waterbody list that strictly meet the size criteria
wb_lst <- st_drop_geometry(WBs_VPU_all) %>% wb_lst <- st_drop_geometry(WBs_VPU_all) %>%
dplyr::filter(FTYPE %in% c("LakePond", "Reservoir") & AREASQKM >= (min_da_km/2)) %>% dplyr::filter(FTYPE %in% c("LakePond", "Reservoir") & AREASQKM >= (min_da_km/2)) %>%
dplyr::select(COMID) dplyr::select(COMID) %>%
filter(!COMID == 166410600)
if (file.exists(data_paths$resops_NID_CW)){ if (file.exists(data_paths$resops_NID_CW)){
# ResOpsUS locations in the VPU waterbody set # ResOpsUS locations in the VPU waterbody set
......
...@@ -64,14 +64,12 @@ if(needs_layer(out_agg_gpkg, agg_cats_layer)){ ...@@ -64,14 +64,12 @@ if(needs_layer(out_agg_gpkg, agg_cats_layer)){
type = rep("terminal", length(missing_outlets)))) type = rep("terminal", length(missing_outlets))))
write_sf(filter(reconciled, ID %in% missing_outlets), out_agg_gpkg, "missing_outlets") write_sf(filter(reconciled, ID %in% missing_outlets), out_agg_gpkg, "missing_outlets")
outlets_terms_fixed <- outlets %>% outlets <- outlets %>%
left_join(select(st_drop_geometry(reconciled), ID, toID), by = "ID") %>% left_join(select(st_drop_geometry(reconciled), ID, toID), by = "ID") %>%
mutate(type = ifelse(type == "terminal" & !is.na(toID), "outlet", type)) %>% mutate(type = ifelse(type == "terminal" & !is.na(toID), "outlet", type)) %>%
select(-toID) select(-toID)
} }
agg_cats <- aggregate_catchments(flowpath = reconciled, agg_cats <- aggregate_catchments(flowpath = reconciled,
divide = divides, divide = divides,
outlets = outlets, outlets = outlets,
......
...@@ -998,13 +998,18 @@ WB_event <- function(WBs, nhd_wb, type){ ...@@ -998,13 +998,18 @@ WB_event <- function(WBs, nhd_wb, type){
inlet_ls <- inlet_FL %>% inlet_ls <- inlet_FL %>%
group_by(LevelPathI) %>% group_by(LevelPathI) %>%
summarize(do_union = T) st_cast("POINT") %>%
summarize(do_union = F) %>%
st_cast("LINESTRING")
inlet_pnts <- sf::st_intersection(inlet_ls, WBs_layer) %>% inlet_pnts <- sf::st_intersection(inlet_ls, WBs_layer) %>%
#group_by("LINESTRING") %>%
st_cast("POINT") %>% st_cast("POINT") %>%
group_by(LevelPathI) %>% st_as_sf()
filter(row_number() == min(row_number())) %>% #mutate(row_id = row_number()) %>%
ungroup() #group_by(LevelPathI) %>%
#filter(row_id == min(row_id)) %>%
#ungroup()
wb_events <- get_flowline_index(nhd_wb, inlet_pnts) %>% wb_events <- get_flowline_index(nhd_wb, inlet_pnts) %>%
inner_join(select(st_drop_geometry(nhd_wb), COMID, WBAREACOMI, LevelPathI), by = "COMID") %>% inner_join(select(st_drop_geometry(nhd_wb), COMID, WBAREACOMI, LevelPathI), by = "COMID") %>%
...@@ -1195,11 +1200,10 @@ wbin_POIcreation <- function(nhd, WBs_VPU, data_paths, crs, split_layer){ ...@@ -1195,11 +1200,10 @@ wbin_POIcreation <- function(nhd, WBs_VPU, data_paths, crs, split_layer){
tmp_POIs, "WBIn") tmp_POIs, "WBIn")
wb_inlet_events <- filter(wb_inlet_events, !COMID %in% wb_inlet_POIs$COMID) wb_inlet_events <- filter(wb_inlet_events, !COMID %in% wb_inlet_POIs$COMID)
if(nrow(wb_inlet_POIs) != nrow(wb_inlet_events)){ if(nrow(wb_inlet_events) > 0){
tmp_POIs <- data.table::rbindlist(list(tmp_POIs, tmp_POIs <- data.table::rbindlist(list(tmp_POIs,
select(wb_inlet_events, COMID, Type_WBIn = WBAREACOMI, nexus) %>% select(wb_inlet_events, COMID, Type_WBIn = WBAREACOMI, nexus)), fill = TRUE) %>%
filter(!COMID %in% tmp_POIs$COMID)), fill = TRUE) %>%
st_as_sf() st_as_sf()
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment