Skip to content

Commit 4dfdf40

Browse files
committed
added warning message to net_delin for duplicated COMID's; fixed names on div_cnt
1 parent 37efc94 commit 4dfdf40

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

StreamNetworkTools/R/net_calc.r

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ net_calc <- function(netdelin, vpu, nhdplus_path ){
7474
diver.cnt <- aggregate(div.rm[, "group.comid"],
7575
by = list(div.rm[, "group.comid"]),
7676
length)
77-
names(diver.cnt) <- c("COMID", "diver.cnt")
78-
} else {
79-
diver.cnt<-data.frame(COMID=99999,div.cnt=999999)
80-
}
77+
names(diver.cnt) <- c("COMID", "diver.cnt")
78+
} else {
79+
diver.cnt<-data.frame(COMID=99999,diver.cnt=999999)
80+
}
8181

8282
#headwaters & Tribs
8383
head.h2o <- aggregate(reach.data[reach.data[,"STARTFLAG"] == 1,

StreamNetworkTools/R/net_delin.r

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,23 @@
3232

3333
net_delin <- function (group_comid, nhdplus_path, vpu, M = NULL) {
3434

35-
if(is.character(group_comid)==F){
35+
if(is.character(group_comid) == F){
3636
stop("group_comid must be character vector")
3737
}
38+
3839
Ms <- M
3940
if (length(Ms) == 0) {
4041
Ms<- rep(1,length(group_comid))
4142
} else if (length(Ms)!= length(group_comid)) {
4243
stop("length(M)!=length(group_comid)")
4344
}
4445

46+
if (any(duplicated(group_comid))) {
47+
warning(paste("duplicated comid:",
48+
group_comid[duplicated(group_comid)],
49+
"network delineated once", sep = " "))
50+
}
51+
group_comid <- unique(group_comid)
4552
directory <- grep(paste(vpu, "/NHDPlusAttributes", sep = ""),
4653
list.dirs(nhdplus_path, full.names = T), value = T)
4754
#to/from comids

0 commit comments

Comments
 (0)