diff --git a/R/2_fixes.R b/R/2_fixes.R index c78a7334d6c98bf1ce7b36d54c75ea7902cf9a12..ab8f99bdc6b9383ed2d0d7c32cd743d06a888253 100644 --- a/R/2_fixes.R +++ b/R/2_fixes.R @@ -1225,6 +1225,8 @@ fix_flowtable <- function(ft, vpu = NULL) { headwater_seed <- read.csv(colClasses = c("character", "integer", "character", "character"), text = "id,mainstem,reachcode,hr_id +152189025,2067862,04100010000605,60001300002967 +{2f4ad41c-c05a-4384-aad4-e98102aa6186},2233910,09040001018728,65000400007291 158347979,2451377,03050208002186,15001500280818 34028295,1794551,18030007000812,50001000103671 29489918,35553,14040102000306,41000800057706 diff --git a/R/99_24k_headwaters.R b/R/99_24k_headwaters.R index ce15cf54a34c31142810ac50266b1acbc5851a36..02b31c7cde5868a34d62e2abc696319a2fb50556 100644 --- a/R/99_24k_headwaters.R +++ b/R/99_24k_headwaters.R @@ -1,7 +1,5 @@ have <- readr::read_csv("review/hr_24k_hw_seed.csv") -have$hr_id[have$COMID == 19577379] - Sys.setenv(TAR_PROJECT = "24k_mainstems_project") # id is final nhd permid @@ -18,18 +16,20 @@ nhdhr_ms_hw$nhdplusid <- nhdhr_to_nhdphr$nhdplusid[match(nhdhr_ms_hw$id, nhdhr_t nhdhr_ms_hw$v3_lp_mainstem <- msv2_to_ms_v3$lp_mainstem_v3[match(nhdhr_ms_hw$LevelPathI, msv2_to_ms_v3$lp_mainstem_v2)] nhdhr_ms_hw$ref_mainstem <- msv2_to_ms_v3$ref_mainstem[match(nhdhr_ms_hw$LevelPathI, msv2_to_ms_v3$lp_mainstem_v2)] -missing <- readLines("missing_headwaters.txt") - -missing <- pbapply::pbsapply(missing, \(x) gsub("before da filter |after da filter ", "", x), USE.NAMES = F) -missing <- sapply(missing, \(x) gsub(" ", "", x), USE.NAMES = F) - -miss <- as.numeric(missing) - -miss <- miss[!is.na(miss)] - -miss <- unique(miss) - -found <- nhdhr_ms_hw[nhdhr_ms_hw$v3_lp_mainstem %in% miss,] +found <- nhdhr_ms_hw[!is.null(nhdhr_ms_hw$v3_lp_mainstem) & !is.null(nhdhr_ms_hw$COMID) & !is.null(nhdhr_ms_hw$nhdplusid),] + +# missing <- readLines("missing_headwaters.txt") +# +# missing <- pbapply::pbsapply(missing, \(x) gsub("before da filter |after da filter ", "", x), USE.NAMES = F) +# missing <- sapply(missing, \(x) gsub(" ", "", x), USE.NAMES = F) +# +# miss <- as.numeric(missing) +# +# miss <- miss[!is.na(miss)] +# +# miss <- unique(miss) +# +# found <- nhdhr_ms_hw[nhdhr_ms_hw$v3_lp_mainstem %in% miss,] found <- dplyr::select(found, dplyr::all_of(c(id = "id", mainstem = "ref_mainstem", COMID = "COMID", hr_id = "nhdplusid", mainstem_v3 = "v3_lp_mainstem"))) diff --git a/_targets/hr_targets.R b/_targets/hr_targets.R index cacd6a87e192a9401116300f000c3f9c2bbec7e8..ff6df479fb8f8b0458e1bad2f8425868218ed565 100644 --- a/_targets/hr_targets.R +++ b/_targets/hr_targets.R @@ -7,7 +7,7 @@ tar_option_set(packages = c("nhdplusTools", "sf", "dplyr", "data.table", storage = "worker", retrieval = "worker", deployment = "main", - error = "null", debug = "no_minor_sub_c70d06770d1db44e") + error = "null") source("R/util.R") source("review/hr_edits.R") @@ -119,7 +119,8 @@ list( #### HEADWATER MATCHING #### tar_target("hr_pairs", get_hr_pairs(hr_path, nhdp_hw_outlets, prj = 5070, cores = 5, max_streamorder = 5)), - tar_target("hr_pairs_extra", add_24k_pairs(hr_pairs, "review/hr_24k_hw_seed.csv")), + tar_target("extra_headwaters", "review/hr_24k_hw_seed.csv", format = "file"), + tar_target("hr_pairs_extra", add_24k_pairs(hr_pairs, extra_headwaters)), tar_target("nhdphr_hw_pairs_joiner", prep_nhdp_atts(nhdp_net)), tar_target("mainstem_order_joiner", prep_mainstem_order(nhdphr_hw_pairs_joiner)), diff --git a/review/headwater_seed.csv b/review/headwater_seed.csv index 9af01acfa8b4128b4c2f2bb9f3176c4bf7de598b..a0294cdd670ded82d9fd8b27efdbdcf71fab4c45 100644 --- a/review/headwater_seed.csv +++ b/review/headwater_seed.csv @@ -1,4 +1,7 @@ id,mainstem,COMID,hr_id,mainstem_v3 +152189025,2067862,15628079,60001300002967,495002 +135633270,NA,10064501,10000300061455,638595 +{B39D5922-6162-4FB0-8C0E-DDF8CF495E91},2573174,14148780,65000100015643,2571795 51387305,353474,19661295,25000300015040,1452326 140599288,,10484705,15000400061004,2273298 160277373,376874,17497017,23001900001397,1709687 diff --git a/review/hr_edits.R b/review/hr_edits.R index c37715fc2697bab0b103302de1dd0957e218907a..719cce13bc05040c1c13cc4830844b5174ff0a12 100644 --- a/review/hr_edits.R +++ b/review/hr_edits.R @@ -28,7 +28,11 @@ remove_nhdhr_lp_mainstems_v3 <- 1979843, 743370, 741825, 744231, 750074, 1408130, 2667128, 30173, 2576600, 124979, 2486066, 2602462, 2652008, 661120, 76670, 355994, 352223, 2359764, 911838, 661104, 2359732, 912856, 912780, 46067, 912857, 911750, 1911020, - 665409, 1574808, 75042, 1066062, 661124, 662069, 662072, 662076, 662058 + 665409, 1574808, 75042, 1066062, 661124, 662069, 662072, 662076, 662058, + 638590, + # 3/17/25 dblodgett + 2281119, 765517, 768870, 116186, 2280340, 495189, 495187, 488507, 495349, 495664, 488511, + readr::read_csv("review/short_nomatch_remove_lpv3.csv")$lp_mainstem ) # these are reference mainstems @@ -56,7 +60,7 @@ ok_hr <- c( 609166,2151015,2151258,2151040,2149117,2146221,2149814,2149240,2145890, 2146292,2142166,2147596,2142626,2143623,2143811,2144315,2144379,2145282, 2154057,2154168,2168996,2169424,2168776,2169382,2169162,2169349,2178494, - 2178664,2389434,2389461,2389571,2390480,2399935,2399184,2397346,2446766, + 2178664,2389434,2389461,2389571,2390480,2399935,2399184,2446766, 2450759,2452092,2452324,2475959, 2467789,2475510,2498518,2507768,2513435, 2514259,2515866,2519073,2219877,2220741,2219311,2657820,2667007,1824872, 1441950,1442355,2318410,2318057,2318114,2318185,2343288,2339996,2339876, @@ -66,7 +70,7 @@ ok_hr <- c( 697693,522430,424121,460506,2233541,2233707,1464757,1459575,2333044,2332953, #new after 12/19/24 added by Brittany 1609836,1860264,1860264,2641568,43678,1610483,317841,2209606,1609836,2236652, - 345050,1916148,1971753,2067862,1969549,851463, 1609319, 38920, + 345050,1916148,1971753,1969549,851463, 1609319, 38920, # added by dblodgett 1/10/25 2100674, #new after 2/10/25 added by Brittany @@ -89,7 +93,9 @@ ok_hr <- c( 747350,735739,601084,1039912,708610,1203117,1703294, #new after 2/18/25, added by Brittany 423856,122739,374357,2092938,546786,2580618,2580330,2580582,2580084,2580560, - 2580371,1758464,1889021,1889848,1890627,2204762,1203117,736285) + 2580371,1758464,1889021,1889848,1890627,2204762,1203117,736285, + # 3/19/24 Blodgett + 2020140) # these are lp_mainstem v3 ok_hr_lpv3 <- c( @@ -97,7 +103,9 @@ ok_hr_lpv3 <- c( 138172, 607748, 609166, 29724, 1194185, 1194284, 29724, 2155397, 2667348, # new after 2/18/25, added Brittany 2593652,1900020,1910008,1948202,603136,626199,638622,2305456,2421815,103051, - 545048,2580142,2508460,1204198,1204198,303353) + 545048,2580142,2508460,1204198,1204198,303353, + # 3/17/25 + 326366, 121910, 636266, 782588, 124209, 488442) # 12/14/24 dblodgett: # These needed to be left in the network in 24k to ensure smaller mainstems @@ -121,4 +129,6 @@ replace_supersede_hr <- c(132535, 1622184, 1622212, 1954163, 2511239, 2510904, 7 767649, 765533, 2091778, 318410, 691326, 2409442, 2183644, 2183699, 659967, 1877551, 1900950, 1900951, 404547, 1891831, 1877551, 1761077, 1962132, 764686, 623593, 2127070, 2046039, 2574231, - 1700855) + 1700855, + # 3/17/25 + 2588989, 2573725, 495326) diff --git a/review/hr_edits.csv b/review/hr_edits.csv index 2bf10e6ff5cd1697fb6cfbc51b1c918384df909e..eebe6ff64f63b4bfe8d9003bc8b3393d36bd04ed 100644 --- a/review/hr_edits.csv +++ b/review/hr_edits.csv @@ -198,3 +198,7 @@ check_comid,change_comid,tonode,fromnode,terminalpa,divergence 23001100000427,23001100000427,23001100002747,,, 60001300004495,60001300004495,60001300009683,,, 23002800044121,23002800044121,23002800145171,,, +15000300039795,15000300039795,150003000397950,,, +50000700047975,50000700047975,50000700019149,,, +22001400019068,22001400019068,22001400013384,,, +23000700050741,23000700050741,23000700075320,,, \ No newline at end of file diff --git a/review/move_before_hr.csv b/review/move_before_hr.csv index 2e107d3d12bf7d0c311ccf330dc9ecc7dd84d9fa..70ab0e8d679d20ccfdc8a2dde31eb8c2aae3d7de 100644 --- a/review/move_before_hr.csv +++ b/review/move_before_hr.csv @@ -144,3 +144,7 @@ move,before 1890057,1889993 757296,757290 2052905,2052514 +2588997,2588991 +526278,521625 +1727998,1727989 +495326,495185 \ No newline at end of file