Skip to content
Snippets Groups Projects
Commit f0fef412 authored by Bock, Andy's avatar Bock, Andy
Browse files

Handling of split cats better

parent c51901d6
No related branches found
No related tags found
1 merge request!169Updates through 07_merge
......@@ -24,6 +24,9 @@ source("R/utils.R")
source("R/config.R")
source("R/NHD_navigate.R")
source("R/hyRefactor_funs.R")
old_path <- Sys.getenv("PATH")
Sys.setenv(PATH = paste(old_path, "C:\\Users\\abock\\AppData\\Roaming\\npm", sep = ";"))
```
This reconcile-catchments step splits and combines catchment boundaries according to the process that was completed in refactor flines.
......@@ -33,13 +36,12 @@ if(needs_layer(out_refac_gpkg, divide_layer)) {
rpu_string <- paste0("rpu_", rpu_code)
fdr <- data_paths$fdr[[rpu_string]]
fac <- data_paths$fac[[rpu_string]]
fdr_temp <- terra::rast(fdr)
raster_crs <- terra::crs(fdr_temp)
# reconciled have no ID applied in refactoring flowlines
reconciled <- st_transform(read_sf(out_refac_gpkg, reconciled_layer), raster_crs)
reconciled <- st_transform(read_sf(out_refac_gpkg, reconciled_layer), raster_crs)
# refactored has the original COMIDs and other attributes
refactored <- st_transform(read_sf(out_refac_gpkg, refactored_layer), raster_crs) %>%
distinct(.keep_all = T)
......@@ -51,25 +53,23 @@ if(needs_layer(out_refac_gpkg, divide_layer)) {
fline_rec = reconciled,
fdr = fdr,
fac = fac,
para = para_reconcile,
para = para_reconcile,
cache = cache_split,
keep = NULL)
keep = NULL)
if(exists("divides")) {
load(cache_split)
split_cats <- bind_rows(split_cats)
split_cats <- bind_rows(split_cats[lengths(split_cats) > 0])
split_cats$areasqkm <- as.numeric(units::set_units(sf::st_area(split_cats), "km^2"))
write_sf(sf::st_transform(split_cats, crs), out_refac_gpkg, split_divide_layer)
unlink(cache_split)
}
unlink(cache_split)
write_sf(sf::st_transform(divides, crs), out_refac_gpkg, divide_layer)
}
......
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