Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mainstems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Water Mission Area
nhgf
mainstems
Commits
f00bc746
Commit
f00bc746
authored
3 months ago
by
Blodgett, David L.
Browse files
Options
Downloads
Patches
Plain Diff
improve headwater handling
parent
023afaf3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
R/4_find_match.R
+15
-2
15 additions, 2 deletions
R/4_find_match.R
with
15 additions
and
2 deletions
R/4_find_match.R
+
15
−
2
View file @
f00bc746
...
@@ -100,13 +100,26 @@ get_hr_pairs <- function(nhdhr_path, nhdplus_hw_outlets, prj, cores = 5, max_str
...
@@ -100,13 +100,26 @@ get_hr_pairs <- function(nhdhr_path, nhdplus_hw_outlets, prj, cores = 5, max_str
dplyr
::
bind_rows
(
hr_pairs
)
dplyr
::
bind_rows
(
hr_pairs
)
}
}
#' add 24k headwater pairs
#' @param hr_pairs id COMID pairs from catchment-based headwater matching
#' @param extra_file character path to file containing previously matched headwaters
#'
add_24k_pairs
<-
function
(
hr_pairs
,
extra_file
)
{
add_24k_pairs
<-
function
(
hr_pairs
,
extra_file
)
{
found
<-
readr
::
read_csv
(
extra_file
,
col_types
=
"ccncc"
)
found
<-
readr
::
read_csv
(
extra_file
,
col_types
=
"ccncc"
)
found
<-
found
[
!
found
$
hr_id
%in%
hr_pairs
$
id
,]
# where a mainstem is in the 24k headwaters but not hr
found_new
<-
found
[
!
found
$
COMID
%in%
hr_pairs
$
COMID
,]
bind_rows
(
select
(
found
,
COMID
,
id
=
hr_id
),
# where the 24k headwaters are different
found_diff
<-
inner_join
(
select
(
found
,
COMID
,
hr_id
),
hr_pairs
,
by
=
"COMID"
)
|>
filter
(
hr_id
!=
id
)
# remove where things are different
hr_pairs
<-
filter
(
hr_pairs
,
!
COMID
%in%
found_diff
$
COMID
)
bind_rows
(
select
(
found_new
,
COMID
,
id
=
hr_id
),
select
(
found_diff
,
COMID
,
id
=
hr_id
),
select
(
hr_pairs
,
COMID
,
id
))
select
(
hr_pairs
,
COMID
,
id
))
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment