Jannik-Schilling / generate_swmm_inp

a QGIS plugin for the import and export of SWMM input files (conversion of geodata, e.g. shapefiles or geopackage into SWMM models and vice versa)
GNU General Public License v2.0
35 stars 10 forks source link

icon generate_swmm_inp

A QGIS plugin which provides tools to create a SWMM input file from layers in QGIS, and to import input files into QGIS. The plugin was recently updated according to new functions in SWMM 5.2. Input files from SWMM 5.1.15 will still work.

Documentation

Link to the documentation file

If you use the plugin in scientific work or other studies, please cite as:

Schilling, J.; Tränckner, J. Generate_SWMM_inp: An Open-Source QGIS Plugin to Import and Export Model Input Files for SWMM. Water 2022, 14, 2262. https://doi.org/10.3390/w14142262

Provided features:

Processing tools (will be added to the processing toolbox)

Additional features

Workflow

0 Install

1 First steps in QGIS

Load a default data set with the first tool and have a look at the layers: There are separate layers for all types of "visible features" in SWMM: junctions, conduits, subcatchments, outfalls, pumps, weirs, ... Further data is provided in tables (which will be saved in the chosen directory) and can be edited there: curves, inflows, options, patterns, quality, timeseries, ...

You can now modify the layers in QGIS with any processing tool. If you want to have different variants of SWMM features (e.g. planning scenarios with various combinations of conduits and junctions), creating new sets of layers (each in one .gpkg file) is recommended.

When editing the attribute tables, the documentation file and the SWMM user manual will help you to find the right columns and suitable values. SWMM sections/infrastructures which are not implemented in the plugin yet (see issue 2) can be added directly in SWMM later.

Now you can write a swmm input file (.inp) and run the simulation with the second tool (2_GenerateSwmmInpFile). You select the layers and tables which you want to use for your new models. The column names of the attribute tables are used by the tool in order to identify the correct information for the inp file. So be careful if you renamed or deleted any columns. You can run the simulation directly in SWMM or with the help of scripts in R or python (see below).

2.1 Create new models from (any) geodata

If you already have layers/tables which you want to use in a new SWMM model, the most convenient approach is to apply the first tool 1_GenerateDefaultData and select "empty layers". The empty layers will already have feature forms for the required fields. Now you can merge your existing geodata with these layers (or copy/paste selected features into the empty layers) and adjust the attribute table (e.g. using the field calculator). When you start from scratch, a useful tool to create a network from a line layer is the QGIS plugin "WaterNetAnalyzer" (available in the QGIS plugin repository or on Github).

Now apply the processing tool (2_GenerateSwmmInpFile) as described above.

2.2 Work with existing inp files (edits)

You can import existing inp files with the third tool (3_ImportInpFile). Creating a new folder (e.g. "swmm_data_v2") for the data is recommended. SWMM not necessarily requires "real" coordinates. QGIS does. So you either need to know the coordinate reference system of the input file or you can try to impoort the input file in any coordinate reference system and (move/rotate/scale) the imported features later. You can choose a prefix (e.g. "v2") which will be added to the layers' names and the data format (.shp, .gpkg, .gml, .kml, .geojson). Some formats seem to have problems with certain coordinate reference systems. GPKG and SHP worked fine so far.

The tool 4_CreateSubModel allows you to simplify an existing model. Again, creating a new folder an working with a prefix for the resulting files is recommended.

3 run simulation / import results from report files

After you ran a simulation in SWMM (or with a python package, see below) you can add the results from a report file. You´ll find the button for the QgisAction in the feature form of a SWMM layer:

“export”

You select the report file, the SWMM feature type and the desired report section. The resulting table will shown as a new table widget.

“export”

You can save the table as a csv file and add it to the QGIS project (if you don´t want this, uncheck the checkbox).

“export”

Now you can join the table to the SWMM layer:

“export”

There´s also a video with a detailled instruction for table joins.

Further useful packages

Python:

R:

Contributing

Funding

First versions of this plugin have been developed within the project PROSPER-RO, funded by BMBF, grant number 033L212