diff --git a/workspace/02_NHD_navigate.Rmd b/workspace/02_NHD_navigate.Rmd index f477ecc116b46e9622129f65ec21c3f461dda19c..ee4db799ae4bf58297a2f979fe58d5ab86c53964 100644 --- a/workspace/02_NHD_navigate.Rmd +++ b/workspace/02_NHD_navigate.Rmd @@ -22,6 +22,7 @@ knitr::opts_chunk$set( source("R/utils.R") source("R/NHD_navigate.R") source("R/hyrefactor_funs.R") +source("../hyfabric/R/poi_creation.R") # increase timeout for data downloads options(timeout=600) @@ -150,7 +151,7 @@ if(all(is.na(tmp_POIs$Type_TE))) { # Derive TE POIs tmp_POIs <- POI_creation(st_drop_geometry(TE_COMIDs), filter(nhd, dend == 1), "TE") %>% - addType(., tmp_POIs, "TE") + addType(., tmp_POIs, "TE") # As a fail-safe, write out list of TE plants not assigned a POI if(nrow(filter(TE_COMIDs, !COMID %in% tmp_POIs$COMID)) > 0) { @@ -184,7 +185,7 @@ if(all(is.na(tmp_POIs$Type_Term))) { select(COMID, LevelPathI) tmp_POIs <- POI_creation(terminal_POIs, nhd, "Term") %>% - addType(., tmp_POIs, "Term") + addType(., tmp_POIs, "Term") write_sf(tmp_POIs, temp_gpkg, nav_poi_layer) } else { @@ -301,7 +302,7 @@ if(all(is.na(tmp_POIs$Type_Conf))) { select(COMID, Type_Conf) tmp_POIs <- POI_creation(conf_COMIDs, filter(nhd, minNet == 1), "Conf") %>% - addType(., tmp_POIs, "Conf") + addType(., tmp_POIs, "Conf") write_sf(nhd, nav_gpkg, nhd_flowline) write_sf(tmp_POIs, temp_gpkg, nav_poi_layer) @@ -327,7 +328,7 @@ if(all(is.na(tmp_POIs$Type_NID))) { # Derive NID POIs tmp_POIs <- POI_creation(NID_COMIDs, filter(nhd, dend ==1), "NID") %>% - addType(., tmp_POIs, "NID", bind = FALSE) + addType(., tmp_POIs, "NID", nexus = TRUE, bind = FALSE) # Write out geopackage layer representing POIs for given theme write_sf(tmp_POIs, temp_gpkg, nav_poi_layer) @@ -343,10 +344,8 @@ mapview(filter(tmp_POIs, Type_NID != ""), layer.name = "NID POIs", col.regions = # Derive or load Waterbody POIs ---------------------- if(all(is.na(tmp_POIs$Type_WBIn))) { - wbout_COMIDs <- filter(tmp_POIs, !is.na(Type_WBOut)) - - wb_layers <- wbin_POIcreation(nhd, WBs_VPU, data_paths, crs, split_layer, wbout_COMIDs) - tmp_POIs <- addType(wb_layers$POIs, tmp_POIs, "WBIn") + wb_layers <- wbin_POIcreation(nhd, WBs_VPU, data_paths, crs, split_layer, tmp_POIs) + tmp_POIs <- wb_layers$POIs if(!all(is.na(wb_layers$events))) { wb_inlet_events <- select(wb_layers$events, -c(id, offset, Hydroseq, ToMeas)) %>% @@ -482,7 +481,7 @@ if(all(is.na(tmp_POIs$Type_Travel))) { unique() tmp_POIs <- POI_creation(select(tt_POIs, COMID, Type_Travel), nhd, "Travel") %>% - addType(., tmp_POIs, "Travel") + addType(., tmp_POIs, "Travel") write_sf(tmp_POIs, temp_gpkg, nav_poi_layer) }else{