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

resolve minor issues

parent 6a6dae0a
No related branches found
No related tags found
1 merge request!182Bock
...@@ -211,7 +211,7 @@ if(needs_layer(temp_gpkg, "WBs_layer_orig")){ ...@@ -211,7 +211,7 @@ if(needs_layer(temp_gpkg, "WBs_layer_orig")){
ref_WB <- WBs_VPU_all %>% ref_WB <- WBs_VPU_all %>%
group_by(wb_id, GNIS_NAME) %>% group_by(wb_id, GNIS_NAME) %>%
sfheaders::sf_remove_holes() %>% sfheaders::sf_remove_holes() %>%
summarize(do_union = T, member_comid = paste(COMID, collapse = ",")) %>% summarize(do_union = TRUE, member_comid = paste(COMID, collapse = ",")) %>%
st_make_valid() %>% st_make_valid() %>%
ungroup() %>% ungroup() %>%
mutate(area_sqkm = as.numeric(st_area(.)) / 1000000) %>% mutate(area_sqkm = as.numeric(st_area(.)) / 1000000) %>%
...@@ -236,6 +236,7 @@ if(!"Type_resops" %in% names(tmp_POIs)){ ...@@ -236,6 +236,7 @@ if(!"Type_resops" %in% names(tmp_POIs)){
mutate(member_comid = as.character(member_comid)) %>% mutate(member_comid = as.character(member_comid)) %>%
distinct() distinct()
# TODO: get this file from data.json
# ResOpsUS locations with attributes from the VPU NHDv2 wb set # ResOpsUS locations with attributes from the VPU NHDv2 wb set
resops_wb_df <- read.csv("data/reservoir_data/istarf_xwalk_final_48_gfv11.csv") %>% resops_wb_df <- read.csv("data/reservoir_data/istarf_xwalk_final_48_gfv11.csv") %>%
# Subset to VPU, only one DAMID per waterbody # Subset to VPU, only one DAMID per waterbody
...@@ -925,6 +926,7 @@ final_POIs_prec <- mutate(final_POIs, id = row_number(), moved = NA) %>% ...@@ -925,6 +926,7 @@ final_POIs_prec <- mutate(final_POIs, id = row_number(), moved = NA) %>%
write_sf(nav_gpkg, nav_poi_layer) write_sf(nav_gpkg, nav_poi_layer)
collapse <- TRUE collapse <- TRUE
# TODO: document what this is doing!
source("R/poi_move.R") source("R/poi_move.R")
check_dups <- final_POIs %>% check_dups <- final_POIs %>%
......
...@@ -177,11 +177,6 @@ if(needs_layer(out_refac_gpkg, outlets_layer)) { ...@@ -177,11 +177,6 @@ if(needs_layer(out_refac_gpkg, outlets_layer)) {
filter(member_COMID == max(member_COMID)) %>% filter(member_COMID == max(member_COMID)) %>%
select(hy_id = COMID, poi_id, member_COMID, reconciled_ID, type) select(hy_id = COMID, poi_id, member_COMID, reconciled_ID, type)
} }
# final_outlets <- outlets_ref_COMID %>%
# st_as_sf() %>%
# inner_join(select(lookup_table, member_COMID, reconciled_ID),
# by = "member_COMID")
write_sf(outlets_ref_COMID, out_refac_gpkg, outlets_layer) write_sf(outlets_ref_COMID, out_refac_gpkg, outlets_layer)
} else { } else {
......
...@@ -183,7 +183,7 @@ if(needs_layer(ND_gpkg, divides_nd)){ ...@@ -183,7 +183,7 @@ if(needs_layer(ND_gpkg, divides_nd)){
if(debug) { if(debug) {
protoHRUs <- divides_lu %>% protoHRUs <- divides_lu %>%
group_by("POI_ID") %>% group_by("POI_ID") %>%
summarize(do_union = T) %>% summarize(do_union = TRUE) %>%
sfheaders::sf_remove_holes(.) %>% sfheaders::sf_remove_holes(.) %>%
st_make_valid() st_make_valid()
write_sf(protoHRUs, ND_gpkg, HRU_layer) write_sf(protoHRUs, ND_gpkg, HRU_layer)
...@@ -223,7 +223,7 @@ if(!"HUC_12" %in% unique(divides_lu$aggStep)){ ...@@ -223,7 +223,7 @@ if(!"HUC_12" %in% unique(divides_lu$aggStep)){
# HRU layer # HRU layer
protoHRUs <- divides_lu %>% protoHRUs <- divides_lu %>%
group_by(POI_ID) %>% group_by(POI_ID) %>%
summarize(do_union = T) %>% summarize(do_union = TRUE) %>%
sfheaders::sf_remove_holes(.) %>% sfheaders::sf_remove_holes(.) %>%
st_make_valid() st_make_valid()
write_sf(protoHRUs, ND_gpkg, HRU_layer) write_sf(protoHRUs, ND_gpkg, HRU_layer)
...@@ -259,7 +259,7 @@ if("Coastline" %in% unique(vpu_nhd$FTYPE)){ ...@@ -259,7 +259,7 @@ if("Coastline" %in% unique(vpu_nhd$FTYPE)){
# HRU layer # HRU layer
protoHRUs <- divides_lu %>% protoHRUs <- divides_lu %>%
group_by(POI_ID) %>% group_by(POI_ID) %>%
summarize(do_union = T) %>% summarize(do_union = TRUE) %>%
sfheaders::sf_remove_holes(.) %>% sfheaders::sf_remove_holes(.) %>%
st_make_valid() st_make_valid()
# Write out updates # Write out updates
...@@ -370,7 +370,7 @@ if(needs_layer(ND_gpkg, missing_cats)){ ...@@ -370,7 +370,7 @@ if(needs_layer(ND_gpkg, missing_cats)){
# Prob HRU - filter(all_hrus, POI_ID == 140402000209) # Prob HRU - filter(all_hrus, POI_ID == 140402000209)
all_hrus <- filter(divides_lu, !is.na(POI_ID)) %>% all_hrus <- filter(divides_lu, !is.na(POI_ID)) %>%
group_by(POI_ID) %>% group_by(POI_ID) %>%
summarize(do_union = T) %>% summarize(do_union = TRUE) %>%
sfheaders::sf_remove_holes(.) %>% sfheaders::sf_remove_holes(.) %>%
nhdplusTools:::check_valid(.) nhdplusTools:::check_valid(.)
...@@ -399,7 +399,7 @@ if(all(!is.na(noagg_divides$POI_ID_noagg))){ ...@@ -399,7 +399,7 @@ if(all(!is.na(noagg_divides$POI_ID_noagg))){
# Prob HRU - filter(all_hrus, POI_ID == 140402000209) # Prob HRU - filter(all_hrus, POI_ID == 140402000209)
all_hrus <- filter(divides_lu, !is.na(POI_ID)) %>% all_hrus <- filter(divides_lu, !is.na(POI_ID)) %>%
group_by(POI_ID) %>% group_by(POI_ID) %>%
summarize(do_union = T) %>% summarize(do_union = TRUE) %>%
sfheaders::sf_remove_holes(.) %>% sfheaders::sf_remove_holes(.) %>%
nhdplusTools:::check_valid(.) nhdplusTools:::check_valid(.)
...@@ -409,4 +409,4 @@ if(all(!is.na(noagg_divides$POI_ID_noagg))){ ...@@ -409,4 +409,4 @@ if(all(!is.na(noagg_divides$POI_ID_noagg))){
print ("account for unaggregated divides") print ("account for unaggregated divides")
} }
``` ```
\ No newline at end of file
...@@ -740,7 +740,7 @@ WB_event <- function(WBs, nhd_wb, type){ ...@@ -740,7 +740,7 @@ WB_event <- function(WBs, nhd_wb, type){
arrange(desc(Hydroseq)) %>% arrange(desc(Hydroseq)) %>%
group_by(LevelPathI) %>% group_by(LevelPathI) %>%
# union together # union together
summarize(do_union = T) %>% summarize(do_union = TRUE) %>%
st_cast("LINESTRING") st_cast("LINESTRING")
WBs_HR <- filter(WBs_layer, source == "HR ID AVAILABLE") WBs_HR <- filter(WBs_layer, source == "HR ID AVAILABLE")
...@@ -1288,7 +1288,7 @@ wb_inlet_collapse <- function(tmp_POIs, nhd, events){ ...@@ -1288,7 +1288,7 @@ wb_inlet_collapse <- function(tmp_POIs, nhd, events){
gage_reach <- gage_ds %>% gage_reach <- gage_ds %>%
group_by(REACHCODE) %>% group_by(REACHCODE) %>%
summarize(do_union = T, summarize(do_union = TRUE,
total_length = sum(LENGTHKM)) total_length = sum(LENGTHKM))
#print(nrow(gage_reach)) #print(nrow(gage_reach))
...@@ -1433,7 +1433,7 @@ wb_poi_collapse <- function(tmp_POIs, nhd, events){ ...@@ -1433,7 +1433,7 @@ wb_poi_collapse <- function(tmp_POIs, nhd, events){
gage_reach <- gage_ds %>% gage_reach <- gage_ds %>%
group_by(REACHCODE) %>% group_by(REACHCODE) %>%
summarize(do_union = T, summarize(do_union = TRUE,
total_length = sum(LENGTHKM)) total_length = sum(LENGTHKM))
#print(nrow(gage_reach)) #print(nrow(gage_reach))
...@@ -1719,4 +1719,4 @@ cs_group <- function(a, athres) { ...@@ -1719,4 +1719,4 @@ cs_group <- function(a, athres) {
result = c(result, group) result = c(result, group)
} }
return (result) return (result)
} }
\ No newline at end of file
...@@ -10,7 +10,7 @@ dissolve_holes <- function(divides_poi){ ...@@ -10,7 +10,7 @@ dissolve_holes <- function(divides_poi){
# HRU layer # HRU layer
protoHRUs <- filter(divides_poi, !is.na(POI_ID)) %>% protoHRUs <- filter(divides_poi, !is.na(POI_ID)) %>%
group_by(POI_ID) %>% group_by(POI_ID) %>%
summarize(do_union = T) %>% summarize(do_union = TRUE) %>%
clean_geometry(., ID = "POI_ID") clean_geometry(., ID = "POI_ID")
agg_noholes <- sfheaders::sf_remove_holes(protoHRUs) %>% agg_noholes <- sfheaders::sf_remove_holes(protoHRUs) %>%
...@@ -502,7 +502,7 @@ NHD_sinks <- function(divides_poi, area_thresh, HUC12_table, NHD_sinks){ ...@@ -502,7 +502,7 @@ NHD_sinks <- function(divides_poi, area_thresh, HUC12_table, NHD_sinks){
# Aggretate sink cats to HUC12 and add area # Aggretate sink cats to HUC12 and add area
sink_cats_agg <- filter(sink_cats, is.na(POI_ID)) %>% sink_cats_agg <- filter(sink_cats, is.na(POI_ID)) %>%
group_by(HUC_12_int) %>% group_by(HUC_12_int) %>%
summarize(do_union = T) %>% summarize(do_union = TRUE) %>%
mutate(agg_id = row_number()) mutate(agg_id = row_number())
m_per_km <- 1000 m_per_km <- 1000
......
## TODO: document this file!
# Load data # Load data
if(collapse){ if(collapse){
......
if(Sys.getenv("sb_user") == "CHANGEME") stop("must set sb_user") if(Sys.getenv("sb_user") == "CHANGEME") stop("must set sb_user")
# Path mods # Path mods
path_mod <- TRUE path_mod <- FALSE
if (path_mod){ if (path_mod){
# 7-zip # 7-zip
old_path <- Sys.getenv("PATH") old_path <- Sys.getenv("PATH")
...@@ -9,11 +9,11 @@ if (path_mod){ ...@@ -9,11 +9,11 @@ if (path_mod){
# Mapshaper # Mapshaper
old_path <- Sys.getenv("PATH") old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste(old_path, "C:\\Users\\abock\\AppData\\Roaming\\npm", sep = ";")) Sys.setenv(PATH = paste(old_path, paste0(Sys.getenv("USERPROFILE"), "AppData\\Roaming\\npm"), sep = ";"))
# Whitebox Tools # Whitebox Tools
library(whitebox) library(whitebox)
wbt_init(exe_path = "C:\\Users\\abock\\AppData\\Roaming\\R\\data\\R\\whitebox\\WBT\\whitebox_tools.exe") wbt_init(exe_path = paste0(Sys.getenv("USERPROFILE"), "AppData\\Roaming\\R\\data\\R\\whitebox\\WBT\\whitebox_tools.exe"))
} }
# CRS for projected and geographic reference systems # CRS for projected and geographic reference systems
......
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