/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)

Primary LanguageQMLGNU General Public License v2.0GPL-2.0

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

  • 1_GenerateDefaultData: Load a default set of layers to your QGIS project

  • 2_GenerateSwmmInpFile: Select a set of layers in QGIS to create an input file for a SWMM simulation

    “export”
  • 3_ImportInpFile: Import an existing SWMM model into QGIS (layers and tables).

    “import”
  • 4_CreateSubModel: Create a submodel (of an existing set of SWMM layers in QGIS) below or above a certain node

Additional features

  • style files (.qml) with custom feature forms for every SWMM layer; The styles will be added to the layers with the first tool. Alternatively you can download the style files or copy them from your QGIS plugin folder “export”
  • import of SWMM report file sections (see below)

Workflow

0 Install

1 First steps in QGIS

Load the default data set with the first tool. Separate layers are provided for all "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. When filling the attribute tables, the documentation file and the SWMM user manual might 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. Saving layer as a new file, e.g. if you want to have different variants of conduits layers, is recommended.

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´ll either need 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 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

  • if you encounter any issues while using the plugin please report here.
  • you can also propose new features and discuss them at the issues page.
  • You can fork this repository to implement your own code and send a pull request

Funding

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