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

Have segments broken out now

parent 071729d2
No related branches found
No related tags found
1 merge request!4Removed "setwd"
......@@ -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)
......
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