Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
reference-hydrofabric
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
Container Registry
Model registry
Operate
Environments
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
reference-hydrofabric
Commits
508aeb8f
Commit
508aeb8f
authored
1 year ago
by
Bock, Andy
Browse files
Options
Downloads
Patches
Plain Diff
Updated POI_creation and AddType functions
parent
e1d4aa1b
No related branches found
No related tags found
1 merge request
!169
Updates through 07_merge
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hyfabric/R/poi_creation.R
+9
-13
9 additions, 13 deletions
hyfabric/R/poi_creation.R
with
9 additions
and
13 deletions
hyfabric/R/poi_creation.R
+
9
−
13
View file @
508aeb8f
...
...
@@ -19,22 +19,15 @@ POI_creation<-function(srcData, nhdDF, IDfield){
POIs
<-
sub_segs
%>%
get_node
(
.
,
position
=
"end"
)
%>%
mutate
(
COMID
=
sub_segs
$
COMID
)
%>%
mutate
(
Type_HUC12
=
NA
,
Type_WBIn
=
NA
,
Type_WBOut
=
NA
,
Type_Gages
=
NA
,
Type_TE
=
NA
,
Type_NID
=
NA
,
Type_Conf
=
NA
,
Type_Term
=
NA
,
Type_Elev
=
NA
,
Type_Travel
=
NA
)
%>%
inner_join
(
srcData
%>%
select
(
COMID
,
ID
),
by
=
"COMID"
)
%>%
mutate
(
!!
(
paste0
(
"Type_"
,
IDfield
))
:=
ID
)
if
(
!
(
paste0
(
"Type_"
,
IDfield
))
%in%
colnames
(
POIs
)){
POIs
<-
POIs
%>%
select
(
COMID
,
Type_HUC12
,
Type_Gages
,
Type_TE
,
Type_NID
,
Type_WBIn
,
Type_WBOut
,
Type_Conf
,
Type_Term
,
Type_Elev
,
Type_Travel
)
}
else
{
POIs
<-
POIs
%>%
select
(
COMID
,
Type_HUC12
,
Type_Gages
,
Type_TE
,
Type_NID
,
Type_WBIn
,
Type_WBOut
,
Type_Conf
,
Type_Term
,
Type_Elev
,
Type_Travel
,
!!
(
paste0
(
"Type_"
,
IDfield
)))
}
mutate
(
!!
(
paste0
(
"Type_"
,
IDfield
))
:=
ID
)
%>%
select
(
COMID
,
!!
(
paste0
(
"Type_"
,
IDfield
)))
%>%
st_as_sf
()
return
(
POIs
)
}
#' Adds the type attribute for co-located POIs of multiple themes
#' @param new_POIs (sf data.frame) new POIs to be tested against existing
#' @param POIs (sf data.frame) Existing POIs
...
...
@@ -87,12 +80,15 @@ addType <- function(new_POIs, POIs, IDfield, nexus = TRUE, bind = TRUE){
# Bind unless indicated not to
if
(
bind
){
POIs_fin
<-
rbind
(
POIs_fin
,
filter
(
new_POIs
,
!
COMID
%in%
POIs_fin
$
COMID
))
POIs_fin
<-
data.table
::
rbindlist
(
list
(
POIs_fin
,
filter
(
new_POIs
,
!
COMID
%in%
POIs_fin
$
COMID
)),
fill
=
TRUE
)
%>%
st_as_sf
()
}
# Add nexus back in if excluded
if
(
nexus
){
POIs_fin
<-
rbind
(
POIs_fin
,
nexus_POIs
)
POIs_fin
<-
data.table
::
rbindlist
(
list
(
POIs_fin
,
nexus_POIs
),
fill
=
TRUE
)
%>%
st_as_sf
()
}
return
(
POIs_fin
)
...
...
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