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

Updated POI_creation and AddType functions

parent e1d4aa1b
No related branches found
No related tags found
1 merge request!169Updates through 07_merge
......@@ -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)
......
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