diff --git a/workspace/003_enhd.Rmd b/workspace/003_enhd.Rmd index 104c41018d4ecedefa410eb23e9d7d1746db27b9..7641b2c5da07822fe8742f1de7f0cd8a1ed9993f 100644 --- a/workspace/003_enhd.Rmd +++ b/workspace/003_enhd.Rmd @@ -12,6 +12,11 @@ Notes: This script updates the catchment topology of NHDPlusV2 with two data sou Most functionality is encapsulated in a `run_plus_attributes` function. ```{r} +# sbtools::item_file_download("5dcd5f96e4b069579760aedb", names = "enhd_nhdplusatts.csv", +# dest_dir = "cache") + +# To create this file, run the following. + library(dplyr) library(sf) @@ -21,8 +26,6 @@ enhd <- data.table::fread("data/ENHDPlusV2_us.txt", sep = ",", integer64 = "char enhd <- as.data.frame(enhd) -# enhd <- data.table::fread("data/e2nhdplusv2_us.csv", sep = ",", integer64 = "character") - nwm <- data.table::fread("data/NWM_v2_1_CONUS_Topology.csv") nwm <- as.data.frame(nwm) @@ -102,8 +105,11 @@ if(file.exists(lp_temp)) { saveRDS(lp, lp_temp) } -net_new <- run_plus_attributes(lp, net_new, "temp/enhd_nhdplusatts.csv", cores = 12) +net_new <- run_plus_attributes(lp, net_new, "cache/enhd_nhdplusatts.csv", cores = 12) +### ONLY RUN IF CHANGED ### +# sbtools::authenticate_sb() +# sbtools::item_replace_files("5dcd5f96e4b069579760aedb", "cache/enhd_nhdplusatts.csv") ``` diff --git a/workspace/00_get_data.Rmd b/workspace/00_get_data.Rmd index 43cd32c93f7420a1ce22818251ec9ce4678231d2..c6ba5860179b9b8939061efdaaced0c93a604865 100644 --- a/workspace/00_get_data.Rmd +++ b/workspace/00_get_data.Rmd @@ -441,6 +441,19 @@ out_list <- c(out_list, out) ``` +```{r nhdplus_attributes} + +out <- list(new_nhdp_atts = file.path("cache", (sb_f <- "enhd_nhdplusatts.csv"))) + +if(!file.exists(out$new_nhdp_atts)) { + sbtools::item_file_download("5dcd5f96e4b069579760aedb", + names = sb_f, + destinations = out) +} + +out_list <- c(out_list, out) +``` + ```{r} write_json(out_list, path = out_file, pretty = TRUE, auto_unbox = TRUE) rm(out_list) diff --git a/workspace/02_NHD_navigate.Rmd b/workspace/02_NHD_navigate.Rmd index fd65689dc045369c57a51ce48b398063d6bcdb71..d9b2e67b625edce6ee409016a9b4610df7822efe 100644 --- a/workspace/02_NHD_navigate.Rmd +++ b/workspace/02_NHD_navigate.Rmd @@ -42,7 +42,7 @@ if(needs_layer(nav_gpkg, temp_POIs)) { if (needs_layer(nav_gpkg, nhdflowline)){ # Subset NHD by VPU - nhd <- VPU_Subset(staged_nhd$flowline, VPU, new_atts = "temp/enhd_nhdplusatts.csv") + nhd <- VPU_Subset(staged_nhd$flowline, VPU, new_atts = data_paths$new_nhdp_atts) # Filter and write dendritic/non-coastal subset to gpkg # This will be iterated over to produce the final network after POIs identified diff --git a/workspace/cache/data_paths.json b/workspace/cache/data_paths.json index 6c0bdef5f5a9d79018876a6b7583f9aa1e4317e5..8421e20d5109ee0a21f32e73c18af937f3420bc6 100644 --- a/workspace/cache/data_paths.json +++ b/workspace/cache/data_paths.json @@ -167,5 +167,6 @@ "merit_catchments": "data/merged_AK_MERIT_Hydro/cat_pfaf_78_81_82_MERIT_Hydro_v07_Basins_v01.shp", "merit_rivers": "data/merged_AK_MERIT_Hydro/riv_pfaf_78_81_82_MERIT_Hydro_v07_Basins_v01.shp", "e2nhd_network": "data/e2nhdplusv2_us.csv", - "nwm_network": "data/NWM_v2_1_CONUS_Topology.csv" + "nwm_network": "data/NWM_v2_1_CONUS_Topology.csv", + "new_nhdp_atts": "cache/enhd_nhdplusatts.csv" }