flipsegs <- function(rivers,whichflip="all") { length <- length(rivers$lines) if(whichflip=="sample") flip <- sample(c(T,F),size=length,replace=T) if(whichflip=="half") flip <- c(rep(T,(floor(length/2))),rep(F,(length-floor(length/2)))) if(whichflip=="all") flip <- rep(T,length) for(i in 1:length(rivers$lines)) { if(flip[i]) { rivers$lines[[i]] <- rivers$lines[[i]][nrow(rivers$lines[[i]]):1,] } } lines <- rivers$lines tolerance <- rivers$tolerance connections <- rivers$connections for(i in 1:length) { for(j in 1:length) { i.max <- dim(lines[[i]])[1] j.max <- dim(lines[[j]])[1] if(pdist(lines[[i]][1,],lines[[j]][1,])