diff --git a/workspace/00_enhd_nwm_network.Rmd b/workspace/00_enhd_nwm_network.Rmd index 1f4a2451179e86d32078de8f781dc96acc8ad846..4c4951c569c863b771333b393d4a1837ff13bc3c 100644 --- a/workspace/00_enhd_nwm_network.Rmd +++ b/workspace/00_enhd_nwm_network.Rmd @@ -151,12 +151,18 @@ net_new$dnlevelpat[is.na(net_new$dnlevelpat)] <- 0 coastal_comids <- nhd_net$comid[nhd_net$terminalfl == 1 & nhd_net$streamleve == 1] -net_new$streamleve <-select(net_new, levelpathi, dnlevelpat, comid) %>% +net_new$streamleve <- select(net_new, levelpathi, dnlevelpat, comid) %>% mutate(coastal = comid %in% coastal_comids) %>% get_streamlevel() net_new$streamorde <- nhdplusTools::get_streamorder(select(net_new, ID = comid, toID = tocomid), status = TRUE) +net_new <- left_join(net_new, + select(nhd_net, comid, vpuin, vpuout, wbareatype, + slope, slopelenkm, ftype, gnis_name, + gnis_id, wbareacomi, hwnodesqkm, rpuid, + vpuid, roughness), by = "comid") + data.table::fwrite(net_new, file = "cache/enhd_nhdplusatts.csv", sep = ",") @@ -204,7 +210,6 @@ arrow::write_parquet(net_new, "cache/enhd_nhdplusatts.parquet") # sbtools::item_replace_files("60c92503d34e86b9389df1c9", "cache/enhd_nhdplusatts.fst") # sbtools::item_replace_files("60c92503d34e86b9389df1c9", "cache/enhd_nhdplusatts.parquet") - ``` ```{r} diff --git a/workspace/07-1_merge.Rmd b/workspace/07-1_merge.Rmd index 52dabef18980e46a90da9fb8277dda6a952d71f6..bb91278db1708bbcdaf7eaef73296a905712a7fd 100644 --- a/workspace/07-1_merge.Rmd +++ b/workspace/07-1_merge.Rmd @@ -32,17 +32,12 @@ For a given VPU bind RPUs into a single geopackage for an entire VPU. This step if(needs_layer(gf_gpkg, agg_cats_layer)) { # Thematic POIs - read_sf(nav_gpkg, final_poi_layer) %>% - st_transform(crs) %>% - write_sf(gf_gpkg, final_poi_layer) + POIs <- read_sf(nav_gpkg, final_poi_layer) %>% + st_transform(crs) - fline <- sf::read_sf(nav_gpkg, nhd_flowline) + write_sf(rfc_gpkg, final_poi_layer) - sf::write_sf(fline, gf_gpkg, nhd_flowline) - - cats <- sf::read_sf(nav_gpkg, nhd_catchment) - - sf::write_sf(cats, gf_gpkg, nhd_catchment) + write_sf(gf_gpkg, final_poi_layer) merged_layers <- merge_refactor(rpu_codes$rpuid, rpu_vpu_out, lookup_table_refactor, @@ -52,13 +47,15 @@ if(needs_layer(gf_gpkg, agg_cats_layer)) { agg_cats_layer, mapped_outlets_layer) - sf::write_sf(merged_layers[[lookup_table_refactor]], gf_gpkg, lookup_table_refactor) + sf::write_sf(merged_layers[[lookup_table_refactor]], rfc_gpkg, lookup_table_refactor) + + sf::write_sf(merged_layers[[reconciled_layer]], rfc_gpkg, reconciled_layer) - sf::write_sf(merged_layers[[reconciled_layer]], gf_gpkg, reconciled_layer) + sf::write_sf(merged_layers[[divide_layer]], rfc_gpkg, divide_layer) - sf::write_sf(merged_layers[[divide_layer]], gf_gpkg, divide_layer) + sf::write_sf(merged_layers[[mapped_outlets_layer]], rfc_gpkg, mapped_outlets_layer) - sf::write_sf(merged_layers[[mapped_outlets_layer]], gf_gpkg, mapped_outlets_layer) + sf::write_sf(merged_layers[[mapped_outlets_layer]], gf_gpkg, mapped_outlets_layer) sf::write_sf(merged_layers[[agg_cats_layer]], gf_gpkg, agg_cats_layer) diff --git a/workspace/R/config.R b/workspace/R/config.R index 9ef5f4a061345d6c4ed5a21a069447202a83a86a..36a3dc2fbde159266a27cc5bafb8d84e1365b5c1 100644 --- a/workspace/R/config.R +++ b/workspace/R/config.R @@ -58,14 +58,15 @@ nhdplus_path(data_paths$nhdplus_gdb) suppressWarnings(staged_nhd <- stage_national_data()) # Defined and used broadly -nhd_flowline <- "nhd_flowline" -nhd_catchment <- "nhd_catchment" +nhd_flowline <- "reference_flowline" +nhd_catchment <- "reference_catchment" +nhd_outlet <- "nhd_outlet" # Created and/or used during 02_Navigate elev_diff <- 500 # Max difference in elevation within a single segment/POI max_elev_TT_DA <- 10 # Min drainage area to consider for elevation/travel_time breaks travt_diff <- 24 # Max number of hours between adjacent POIS -nav_gpkg <- file.path("cache", paste0("reference_", vpu,".gpkg")) + xwalk_layer <- paste0("HUC12_nhd") # HUC12 - nhdcat crosswalk, built in Nav for VPU 20 nav_poi_layer <- paste0("POIs_tmp_", vpu) # Rolling Nav POI layer added to/modified througout nav workflow WBs_layer <- paste0("WB_", vpu) # Waterbodies within VPU @@ -73,7 +74,7 @@ poi_moved_layer <- paste0("POIs_mv_", vpu) # POIs moved from original COMID assi nsegments_layer <- paste0("nsegment_", vpu) # Minimally-sufficient network dissolved by POI_ID pois_all_layer <- paste0("POIs_", vpu) # All POIs binded together poi_xwalk_layer <- paste0("poi_xwalk_layer_", vpu) # POIs that changed COMIDS during the navigate part of the workflow -final_poi_layer <- "final_POIS" +final_poi_layer <- "POIs" # Settings for refactor workflow split_meters <- 10000 @@ -85,25 +86,30 @@ para_reconcile <- 2 para_split_flines <- 2 keep_cat_points <- 1 -nhd_outlet <- "nhd_outlet" -nhd_catchment <- "nhd_catchment" + # Created during refactor workflow refactored_layer <- "collapsed" -reconciled_layer <- "reconciled" +reconciled_layer <- "refactored_flowpaths" split_layer <- "split_events" -divide_layer <- "divides" -agg_fline_layer <- "agg_fline" -agg_cats_layer <- "agg_cats" +divide_layer <- "refactored_divides" +agg_fline_layer <- "aggregated_flowpaths" +agg_cats_layer <- "aggregated_divides" outlets_layer <- "outlets" -mapped_outlets_layer <- "mapped_outlets" +mapped_outlets_layer <- "mapped_POIs" lookup_table_refactor <- "lookup_table" +# output geopackage file names +nav_gpkg <- file.path("cache", paste0("reference_", vpu,".gpkg")) + +rfc_gpkg <- file.path("cache", paste0("refactor_", vpu, ".gpkg")) + gf_gpkg <- file.path("cache", paste0("GF_", vpu, ".gpkg")) gf_gpkg_conus <- "cache/reference_CONUS.gpkg" # Defined during NonDend.Rmd ND_gpkg <- file.path("cache", paste0("ND_", vpu,".gpkg")) + divides_xwalk <- paste0("divides_nhd") HRU_layer <- paste0("all_cats") divides_nd <- paste0("divides_nd")