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

debug work

parent a7bec53d
No related branches found
No related tags found
1 merge request!123Clean Up
......@@ -71,10 +71,17 @@ for(VPU in vpu_codes) {
write_sf(nhd, nav_gpkg, nhd_flowline)
cats_rpu <- full_cat_table %>%
filter(RPUID %in% rpu_codes$rpuid)
cats <- catchment %>%
filter(FEATUREID %in%
unique(c(nhd$COMID,
full_cat_table$FEATUREID[full_cat_table$RPUID %in% rpu_codes])))
full_cat_table$FEATUREID[full_cat_table$RPUID %in% rpu_codes$rpuid]))) %>%
mutate(hy_cats = ifelse(FEATUREID %in% nhd$COMID, 1, 0),
full_cats = ifelse(FEATUREID %in% cats_rpu$FEATUREID, 1, 0)) %>%
filter(full_cats == 1 | hy_cats == 1) %>%
st_sf()
write_sf(cats, nav_gpkg, nhd_catchment)
......
......@@ -68,7 +68,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 <- paste0("final_POIS_", vpu)
final_poi_layer <- paste0("final_POIS")
# Settings for refactor workflow
split_meters <- 10000
......
......@@ -333,9 +333,13 @@ merge_refactor <- function(rpus, rpu_vpu_out,
update_id <- sf::st_drop_geometry(select(out[[rpu]][[reconciled_layer]],
old_ID = ID, ID = newID))
out[[rpu]][[lookup_table_refactor]] <- left_join(out[[rpu]][[lookup_table_refactor]],
update_id,
by = c("reconciled_ID" = "old_ID"))
out[[rpu]][[lookup_table_refactor]] <- out[[rpu]][[lookup_table_refactor]] %>%
left_join(update_id, by = c("reconciled_ID" = "old_ID")) %>%
select(-reconciled_ID, reconciled_ID = ID) %>%
left_join(update_id, by = c("aggregated_flowline_ID" = "old_ID")) %>%
select(-aggregated_flowline_ID, aggregated_flowline_ID = ID) %>%
left_join(update_id, by = c("aggregated_catchment_ID" = "old_ID")) %>%
select(-aggregated_catchment_ID, aggregated_catchment_ID = ID)
out[[rpu]][[divide_layer]] <- left_join(rename(out[[rpu]][[divide_layer]], old_ID = ID),
update_id,
......@@ -387,14 +391,18 @@ merge_refactor <- function(rpus, rpu_vpu_out,
tidyr::unnest(cols = member_COMID) %>%
mutate(NHDPlusV2_COMID = as.integer(member_COMID)) %>%
select(-member_COMID, update_newtoID = newID)
# NOTE: if the missing tocomid is in the next VPU they will still be NA
out[[reconciled_layer]] <- left_join(out[[reconciled_layer]],
long_form, by = c("toCOMID" = "NHDPlusV2_COMID"))
out[[reconciled_layer]]$newtoID[!is.na(out[[reconciled_layer]]$toCOMID)] <-
out[[reconciled_layer]]$update_newtoID[!is.na(out[[reconciled_layer]]$toCOMID)]
out[[reconciled_layer]] <- select(out[[reconciled_layer]], ID = newID, toID = newtoID, LENGTHKM, TotDASqKM, member_COMID, refactor_ID = ID)
if("toCOMID" %in% names(out[[reconciled_layer]])) {
# NOTE: if the missing tocomid is in the next VPU they will still be NA
out[[reconciled_layer]] <- left_join(out[[reconciled_layer]],
long_form, by = c("toCOMID" = "NHDPlusV2_COMID"))
out[[reconciled_layer]]$newtoID[!is.na(out[[reconciled_layer]]$toCOMID)] <-
out[[reconciled_layer]]$update_newtoID[!is.na(out[[reconciled_layer]]$toCOMID)]
}
out[[reconciled_layer]] <- select(out[[reconciled_layer]], ID = newID,
toID = newtoID, LENGTHKM, TotDASqKM,
member_COMID, refactor_ID = ID)
out
}
......@@ -2,7 +2,7 @@
## workflows. These should be run prior to checking in any changes to these
## workflows.
VPU <- vpu_codes <- "14"
VPU <- vpu_codes <- "04"
source("R/config.R")
source("R/utils.R")
......@@ -16,7 +16,7 @@ for(r in rpu_codes$rpuid) {
}
rmarkdown::render('01_NHD_prep.Rmd',
output_file='temp/02_NHD_navigate_test.html')
output_file='temp/01_NHD_prep_test.html')
rmarkdown::render('02_NHD_navigate.Rmd',
output_file='temp/02_NHD_navigate_test.html')
......
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