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

config updates

parent b367116a
No related branches found
No related tags found
1 merge request!68Alaska and full workflow -- should work with this.
......@@ -35,9 +35,9 @@ nhd_rds <- fix_headwaters(staged_nhd$flowline, gsub("flowline.rds", "flowline_up
```{r huc12 POIs}
# Derive or load HUC12 POIs ----------------------
# Still need to deal with some duplicate HUC12s
if(needs_layer(nav_gpkg, temp_POIs)) {
if(needs_layer(nav_gpkg, nav_poi_layer)) {
if (needs_layer(nav_gpkg, nhdflowline)){
if (needs_layer(nav_gpkg, nhd_flowline)){
# Subset NHD by VPU
nhd <- VPU_Subset(nhd_rds, VPU)
......@@ -53,9 +53,9 @@ if(needs_layer(nav_gpkg, temp_POIs)) {
mutate(dend = ifelse(!COMID %in% non_dend, 1, 0),
poi = ifelse(!COMID %in% non_dend & TotDASqKM >= min_da_km, 1, 0))
write_sf(nhd, nav_gpkg, nhdflowline)
write_sf(nhd, nav_gpkg, nhd_flowline)
} else {
nhd <- read_sf(nav_gpkg, nhdflowline)
nhd <- read_sf(nav_gpkg, nhd_flowline)
try(nhd <- select(nhd, -c(minNet, WB, struct_POI, struct_Net, POI_ID)))
}
......@@ -72,13 +72,13 @@ if(needs_layer(nav_gpkg, temp_POIs)) {
huc12_POIs <- POI_creation(st_drop_geometry(HUC12_COMIDs), filter(nhd, poi == 1), "HUC12")
# Write out geopackage layer representing POIs for given theme
write_sf(huc12_POIs, nav_gpkg, temp_POIs)
write_sf(huc12_POIs, nav_gpkg, nav_poi_layer)
tmp_POIs <- huc12_POIs
} else {
# Load HUC12 POIs as the tmpPOIs if they already exist
tmp_POIs <- read_sf(nav_gpkg, temp_POIs)
nhd <- read_sf(nav_gpkg, nhdflowline)
tmp_POIs <- read_sf(nav_gpkg, nav_poi_layer)
nhd <- read_sf(nav_gpkg, nhd_flowline)
}
```
......@@ -103,9 +103,9 @@ if(all(is.na(tmp_POIs$Type_Gages))) {
addType(., tmp_POIs, "Gages")
# Write out geopackage layer representing POIs for given theme
write_sf(tmp_POIs, nav_gpkg, temp_POIs)
write_sf(tmp_POIs, nav_gpkg, nav_poi_layer)
} else {
tmp_POIs <- read_sf(nav_gpkg, temp_POIs)
tmp_POIs <- read_sf(nav_gpkg, nav_poi_layer)
}
```
......@@ -129,10 +129,10 @@ if(all(is.na(tmp_POIs$Type_TE))) {
addType(., tmp_POIs, "TE")
# Write out geopackage layer representing POIs for given theme
write_sf(tmp_POIs, nav_gpkg, temp_POIs)
write_sf(tmp_POIs, nav_gpkg, nav_poi_layer)
} else {
# Load TE POIs if they already exist
tmp_POIs <- read_sf(nav_gpkg, temp_POIs)
tmp_POIs <- read_sf(nav_gpkg, nav_poi_layer)
}
```
......@@ -163,11 +163,11 @@ if(all(is.na(tmp_POIs$Type_Conf))) {
tmp_POIs <- POI_creation(conf_COMIDs, filter(nhd, dend ==1), "Conf") %>%
addType(., tmp_POIs, "Conf")
write_sf(nhd, nav_gpkg, nhdflowline)
write_sf(tmp_POIs, nav_gpkg, temp_POIs)
write_sf(nhd, nav_gpkg, nhd_flowline)
write_sf(tmp_POIs, nav_gpkg, nav_poi_layer)
} else {
nhd <- read_sf(nav_gpkg, nhdflowline)
tmp_POIs <- read_sf(nav_gpkg, temp_POIs)
nhd <- read_sf(nav_gpkg, nhd_flowline)
tmp_POIs <- read_sf(nav_gpkg, nav_poi_layer)
}
```
......@@ -187,10 +187,10 @@ if(all(is.na(tmp_POIs$Type_NID))) {
addType(., tmp_POIs, "NID", bind = FALSE)
# Write out geopackage layer representing POIs for given theme
write_sf(tmp_POIs, nav_gpkg, temp_POIs)
write_sf(tmp_POIs, nav_gpkg, nav_poi_layer)
} else {
# Load NID POIs if they already exist
tmp_POIs <- read_sf(nav_gpkg, temp_POIs)
tmp_POIs <- read_sf(nav_gpkg, nav_poi_layer)
}
```
......@@ -207,7 +207,7 @@ if(all(is.na(tmp_POIs$Type_WBOut))) {
st_sf()
# Write out waterbodies
write_sf(st_transform(WBs_VPU, 4269), nav_gpkg, WBs)
write_sf(st_transform(WBs_VPU, 4269), nav_gpkg, WBs_layer)
# Segments that are in waterbodies
nhd <- mutate(nhd, WB = ifelse(WBAREACOMI > 0 & WBAREACOMI %in% WBs_VPU$COMID, 1, 0))
......@@ -233,11 +233,11 @@ if(all(is.na(tmp_POIs$Type_WBOut))) {
tmp_POIs <- POI_creation(filter(wbin_COMIDs, !COMID %in% wbout_COMIDs$COMID), filter(nhd, poi == 1), "WBIn") %>%
addType(., tmp_POIs, "WBIn")
write_sf(nhd, nav_gpkg, nhdflowline)
write_sf(tmp_POIs, nav_gpkg, temp_POIs)
write_sf(nhd, nav_gpkg, nhd_flowline)
write_sf(tmp_POIs, nav_gpkg, nav_poi_layer)
} else {
tmp_POIs <- read_sf(nav_gpkg, temp_POIs)
nhd <- read_sf(nav_gpkg, nhdflowline)
tmp_POIs <- read_sf(nav_gpkg, nav_poi_layer)
nhd <- read_sf(nav_gpkg, nhd_flowline)
}
```
......@@ -281,7 +281,7 @@ if(needs_layer(nav_gpkg, pois_all)) {
```{r Final segments}
# Derive first cut of segments ----------------------
if(needs_layer(nav_gpkg, n_segments)) {
if(needs_layer(nav_gpkg, nsegments_layer)) {
# Sort POIs by Levelpath and Hydrosequence in upstream to downstream order
seg_POIs <- filter(st_drop_geometry(nhd), COMID %in% tmp_POIs$COMID, COMID %in% filter(nhd, minNet == 1)$COMID)
......@@ -303,13 +303,13 @@ if(needs_layer(nav_gpkg, n_segments)) {
mutate(struct_POI = ifelse(COMID %in% strucFeat$struc_POIs$COMID, 1, 0),
struct_Net = ifelse(COMID %in% strucFeat$structnet$COMID, 1, 0))
write_sf(nhd_Final, nav_gpkg, nhdflowline)
write_sf(nsegments, nav_gpkg, n_segments)
write_sf(nhd_Final, nav_gpkg, nhd_flowline)
write_sf(nsegments, nav_gpkg, nsegments_layer)
} else {
# Read in NHDPlusV2 flowline simple features and filter by vector processing unit (VPU)
final_POIs <- read_sf(nav_gpkg, pois_all)
nhd_Final <- read_sf(nav_gpkg, nhdflowline)
nsegments <- read_sf(nav_gpkg, n_segments)
nhd_Final <- read_sf(nav_gpkg, nhd_flowline)
nsegments <- read_sf(nav_gpkg, nsegments_layer)
}
# Ensure that all the problem POIs have been taken care of
......@@ -331,11 +331,11 @@ if(needs_layer(nav_gpkg, pois_merge)) {
# Write out geopackage layer representing POIs for given theme
write_sf(out_HUC12$allPOIs, nav_gpkg, pois_merge)
write_sf(nhd_Final, nav_gpkg, nhdflowline)
write_sf(out_HUC12$segs, nav_gpkg, n_segments)
write_sf(nhd_Final, nav_gpkg, nhd_flowline)
write_sf(out_HUC12$segs, nav_gpkg, nsegments_layer)
} else {
final_POIs <- read_sf(nav_gpkg, pois_merge)
nhd_Final <- read_sf(nav_gpkg, nhdflowline)
nsegments <- read_sf(nav_gpkg, n_segments)
nhd_Final <- read_sf(nav_gpkg, nhd_flowline)
nsegments <- read_sf(nav_gpkg, nsegments_layer)
}
```
......@@ -37,7 +37,7 @@ Load and filter source NHD Flowline network.
if(needs_layer(out_gpkg, nhd_flowline)) {
# Determine which Flowlines are in scope, previously implemented in NHD_Navigate
nhd <- read_sf(gf_gpkg, "NHDFlowline") %>%
nhd <- read_sf(gf_gpkg, "nhd_flowline") %>%
subset_rpu(rpu_code, run_make_standalone = TRUE) %>%
st_sf()
......
......@@ -41,6 +41,8 @@ if(!nchar(cache_split <- Sys.getenv("CACHE_SPLIT")) > 5)
if(!nchar(lookup_table_file <- Sys.getenv("LOOKUP_TABLE")) > 5)
lookup_table_file <- file.path("cache", paste0(rpu_code, "_lookup.csv"))
options(scipen = 9999)
# Source Data
crs <- 5070
data_paths <- jsonlite::read_json(file.path("cache", "data_paths.json"))
......
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