SWMMR is an R package to interface the EPA Storm Water Management Model (SWMM). It can modify SWMM input files, run SWMM, and read SWMM binary output files.
- Install
devtools
(type in the R command line)
install.packages("devtools")
- Install SWMMR (type in the R command line)
library(devtools)
install_github("scheidan/SWMMR")
This is a minimal example, see the package help for more options.
library(SWMMR)
## Run SWMM
runSWMM(inputfile = "input.inp",
reportfilename="report.rpt",
outputfilename="output.out",
SWMMexe="swmm5.exe")
## Run SWMM with given parameters
## The input file is now used as template:
## All strings "{area}" and "{width}" in the input file are
## replaced by the values given by 'parameter'.
runSWMM(parameter = c(area=10, width=4),
inputfile = "input_template.inp",
reportfilename="report.rpt",
outputfilename="output.out",
SWMMexe="swmm5.exe")
## Read output file
resfile <- openSWMMOutput("output.out")
resfile # print summary
readSubcatchments(resfile, names=c("S1", "S2", "S3"), variables=c("rainfall", "runoff"))
readNodes(resfile, names="Nod1") # read all variables for node "Nod1"
readLinks(resfile, names=NULL, variables=NULL) # read all variables for all links
readSystem(resfile) # read all system variables
closeSWMMOutput(resfile) # close file
An alternative is the swmmr package by Dominik Leutnant. It should be faster (due file reader written in C++), the interface is more low-level compared to SWMMR.
This package is based on this work of Peter Steinberg.