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
78e39900
Commit
78e39900
authored
5 years ago
by
Bock, Andy
Browse files
Options
Downloads
Patches
Plain Diff
Have segments broken out now
parent
071729d2
No related branches found
No related tags found
1 merge request
!4
Removed "setwd"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
NHD_navigate.R
+12
-2
12 additions, 2 deletions
NHD_navigate.R
with
12 additions
and
2 deletions
NHD_navigate.R
+
12
−
2
View file @
78e39900
...
...
@@ -22,9 +22,11 @@ NetworkNav<-function(inCom,nhdDF,navType){
if
(
navType
==
"up"
){
# Upstream network navigation
Seg
<-
nhdplusTools
::
get_UM
(
nhdDF
,
inCom
,
include
=
T
)
nhdDF
$
POI_ID
[
nhdDF
$
COMID
%in%
Seg
&
nhdDF
$
POI_ID
==
0
]
<<-
inCom
}
else
{
# Downstream network navigation (distance currently hard-coded)
Seg
<
nhdplusTools
::
get_DM
(
nhdDF
,
inCom
,
distance
=
1050
,
include
=
T
)
# subset all segs not equal to 0, assign the lowest HS value
}
return
(
Seg
)
}
...
...
@@ -37,6 +39,7 @@ POI_creation<-function(inSegs){
# subset the last point from each geometry, make a POINT sf object
Seg_ends
<-
sapply
(
Segpts
,
function
(
p
)
{
p
[
c
(
length
(
p
))]})
%>%
sf
::
st_sfc
()
%>%
sf
::
st_sf
(
'geom'
=
.
)
Seg_ends
$
COMID
<-
huc12POIsegs
$
COMID
return
(
Seg_ends
)
}
...
...
@@ -75,6 +78,8 @@ nhdDF<-readRDS("data/nhdplus_flowline_attributes.rds") # %>% select(COMID, Pathl
nhd
<-
readRDS
(
"data/nhdplus_flowline.rds"
)
# Return flowlinest that are POIs
huc12POIsegs
<-
nhd
%>%
dplyr
::
filter
(
COMID
%in%
comIDs
[,
1
])
# 15 missing?
# Sort data frame by highest-> lowest LP, then subsequently highest->lowest HS within each LP
huc12POIsegs
<-
huc12POIsegs
%>%
dplyr
::
arrange
(
desc
(
LevelPathI
),
desc
(
Hydroseq
))
#########################
# Create POIs from HUC12 segments
...
...
@@ -85,10 +90,11 @@ write_rds(huc12POIs,path="workspace/huc12POIS.rds")
##########################
# Navigate upstream along the mainstems from HUC12 POIS
upNet
<-
unique
(
unlist
(
lapply
(
comIDs
,
NetworkNav
,
nhdDF
,
"up"
)))
nhdDF
$
POI_ID
<
-0
upNet
<-
unique
(
unlist
(
lapply
(
comIDs
[,
1
],
NetworkNav
,
nhdDF
,
"up"
)))
# Subset by dangling segments that need downstream navigation to be connected
# reduces the number of features we need to connect
upNet_DF
<-
nhd
%>%
dplyr
::
filter
(
COMID
%in%
upNet
)
%>%
upNet_DF
<-
nhd
%>%
dplyr
::
filter
(
COMID
[,
1
]
%in%
upNet
)
%>%
filter
(
!
DnHydroseq
%in%
Hydroseq
)
# Nagivate downstream along the mainstems
downNet
<-
unique
(
unlist
(
lapply
(
upNet_DF
$
COMID
,
NetworkNav
,
nhdDF
,
"down"
)))
...
...
@@ -109,6 +115,7 @@ confluences<-nhdConf %>% dplyr::group_by(DnHydroseq) %>% dplyr::filter(n()>1) %>
# Create POIs from HUC12 segments
huc12POIs
<-
POI_creation
(
confluences
)
# get all conf pois with flowlines with dummy ==
# Write out shapefile representing POIs for given theme
sf
::
st_write
(
conf_ends
,
dsn
=
"workspace/confPOIs.shp"
,
delete_dsn
=
T
)
...
...
@@ -117,6 +124,9 @@ write_rds(conf_ends,path="workspace/confPOIs.rds")
##########################################
##############DEPRECATED SECTION##################
segs
<-
nhdDF
%>%
filter
(
POI_ID
>
0
)
nhdSegs
<-
nhd
%>%
inner_join
(
segs
,
by
=
c
(
'COMID'
=
'COMID'
))
%>%
select
(
COMID
,
POI_ID
,
Shape
)
# # retrieve POI from seg (this is deprecated)
# retrievePOI<-function(nhdPOI){
# #print (iter)
...
...
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