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

get new nhdplus attributes checked into scripts

parent 0618def9
No related branches found
No related tags found
1 merge request!57get new nhdplus attributes checked into scripts
......@@ -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")
```
......@@ -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)
......
......@@ -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
......
......@@ -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"
}
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