This is an output file for Floodplain maximum discharge from Flo-2D modeling. I was running with an issue. I have attached one sheet with 5 Floodplain cross-sections discharge. In the actual sheet, I have 1500 of them. You can download the file from the below mentioned link.
CROSSMAX.OUT file from Flo-2D modeling
This is the code developed to extract flow values from the above mentioned file.
rm(list=ls())
#working directory
workDir <- "C:/Users/PKuranjekar/Desktop/Thumb drive/GIS Toolbox/R/reneedyourhelpmann/"
setwd(workDir)
#read data
inData <- readLines("CROSSMAX2.txt")
#extract lines with the phrase "CROSS SECTION"
inData2 <- inData[grep("CROSS SECTION", inData)]
#remove spaces
inData2 <- gsub(" ", "", inData2)
#split text using ":"
inData2 <- do.call(rbind,strsplit(inData2, ":"))
#identify flow
cfs <- do.call(rbind,strsplit(inData2[,2], "CFS"))[,1]
#identify cross-section number
cs <- do.call(rbind,strsplit(inData2[,1], "SECTION"))[,2]
cs <- gsub("IS", "", cs)
#create output
outData <- data.frame(cs, cfs, stringsAsFactors=FALSE)
#write output
write.table(outData, "CROSSMAX2_output.txt", sep="\t", row.names=FALSE, quote=FALSE, na="")
The output of this code will be
Number of c/s Discharge
1 185.94
2 88.34
3 344.34
4 370.94
5 444.72
and so on
CROSSMAX.OUT file from Flo-2D modeling
This is the code developed to extract flow values from the above mentioned file.
rm(list=ls())
#working directory
workDir <- "C:/Users/PKuranjekar/Desktop/Thumb drive/GIS Toolbox/R/reneedyourhelpmann/"
setwd(workDir)
#read data
inData <- readLines("CROSSMAX2.txt")
#extract lines with the phrase "CROSS SECTION"
inData2 <- inData[grep("CROSS SECTION", inData)]
#remove spaces
inData2 <- gsub(" ", "", inData2)
#split text using ":"
inData2 <- do.call(rbind,strsplit(inData2, ":"))
#identify flow
cfs <- do.call(rbind,strsplit(inData2[,2], "CFS"))[,1]
#identify cross-section number
cs <- do.call(rbind,strsplit(inData2[,1], "SECTION"))[,2]
cs <- gsub("IS", "", cs)
#create output
outData <- data.frame(cs, cfs, stringsAsFactors=FALSE)
#write output
write.table(outData, "CROSSMAX2_output.txt", sep="\t", row.names=FALSE, quote=FALSE, na="")
The output of this code will be
Number of c/s Discharge
1 185.94
2 88.34
3 344.34
4 370.94
5 444.72
and so on
No comments:
Post a Comment