Code Monkey home page Code Monkey logo

qgis-swmm's Introduction

QGIS swmm plugin

Extends processing framework to models storm water management systems.

This plugin lets you model hydraulic network for water and run simulations to get water flow rate informations and more.

Requirements

You need :

  • A working version of SWMM
  • QGIS > 2.0
  • The QGIS Processing framework

Installation

You need to have swmm as a command line tool for the plugin to work.

Install SWMM for Windows

Download and run https://www.epa.gov/sites/production/files/2018-08/swmm51013_setup_1.exe

Compile SWMM for linux

Download Epanet sources from https://www.epa.gov/sites/production/files/2018-08/swmm51013_engine_0.zip

For linux:

mkdir swmm
cd swmm
wget https://www.epa.gov/sites/production/files/2018-08/swmm51013_engine_0.zip
unzip swmm51006_engine_0.zip
unzip source5_1_006.zip
unzip -o makefiles.zip 
unzip -o GNU-CLE.zip

Open the file swmm5.c, comment out the line

#define DLL

and uncomment the line

#define CLE

also comment the line

#include <direct.h>

Open the file Makefile and replace the line (line 12)

cc -o swmm5 -lm $(objs)

by

cc -o swmm5 $(objs) -lm 

and remove the misplaced backslash from the last line of the objs definition (line 8)

Then run:

make

Install the plugin

Simply put this directory in the plugin directory. On linux:

cd ~/.qgis2/python/plugins
git clone https://github.com/Oslandia/qgis-swmm.git

You then need to run QGIS, install the processing plugin and configure the path to the swmm executable in QGIS menu Processing -> Options and configuration.

Running the example

A simple example is provided to test the plugin. You need a working postgres/postgis server in order to use the example.

First create a test database, from the installation root directory run:

createdb swmm_test
psql swmm_test -f example/example1_test_db.sql

Open QGIS, click on 'Add Postgis Layer', configure a new connection to swmm_test database and connect. Check 'Also list tables with no geometry' and select following layers from the plublic schema (layers with geometry are duplicated in the list, make sure you select the entry with a geometry):

  • conduits (geom)
  • controls
  • curves
  • evaporation
  • inflows
  • junctions (geom
  • options
  • outfalls (geom)
  • pumps (geom)
  • report
  • storage (geom)
  • timeseries
  • xsections

Open the processing toobox and double-click on the incon Swmm... -> Simulation -> Simulate...

If you are running a fresh buid from QGIS master, the name of the parameters are already set (recognized from layer names). If you running an older version of QGIS, you must set the following parameter:

  • Analysis options -> options
  • Output reporting instruction -> report
  • Evaporation data -> evaporation
  • Junctions node information -> junctions
  • Outfall node information -> outfalls
  • Storage node information -> storage
  • Conduit link information -> conduits
  • Pump link information -> pumps
  • Conduit, orifice, and weir cross-section geometry -> xsections
  • Rules that control pump and regulator operation -> controls
  • External hydrograph/pollutograph inflow at nodes -> inflows
  • x-y tabular data references in other sections -> curves
  • Time series data referenced in other sections -> timeseries

Then click on Run. Three result layers should appear in the project once the simualtion is complete.

Credits

This plugin has been developed by Oslandia ( http://www.oslandia.com ).

Oslandia provides support and assistance for QGIS and associated tools, including this plugin.

This work has been funded by European funds. Thanks to the GIS Office of Apavil, Valcea County (Romania)

Licence

This work is free software and licenced under the GNU GPL version 2 or any later version. See LICENCE file.

Known issue

In SwmmAlgorithm.py the first argument of subprocess.Popen should be the list [swmm_cli, filename, outfilename], but for some reason this does not seem to work. On windows, if you can't obtain the results after running the example, try changing this line.

qgis-swmm's People

Contributors

mach0 avatar sjib avatar sylvainbeo avatar vmora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qgis-swmm's Issues

no output file

I saw previously someone had this issue because of time stamps and saw that you had corrected the code. When I run the plugin with sample data it will create the swmm.inp but not the swmm.out, with a log message of
2017-04-16T00:46:35 2 Uncaught error while executing algorithm
Traceback (most recent call last):
File "/usr/share/qgis/python/plugins/processing/core/GeoAlgorithm.py", line 203, in execute
self.processAlgorithm(progress)
File "/home/jordan/.qgis2/python/plugins/qgis-swmm/SwmmAlgorithm.py", line 254, in processAlgorithm
f = codecs.open(filename,'w',encoding='utf-8')
File "/usr/lib/python2.7/codecs.py", line 896, in open
file = builtin.open(filename, mode, buffering)
IOError: [Errno 13] Permission denied: u'/home/jordan/.qgis2//processing/outputs/swmm.inp'

2017-04-16T00:47:02 0 /bin/sh: 1: /home/jordan/swmm: Permission denied

2017-04-16T00:47:02 2 Uncaught error while executing algorithm
Traceback (most recent call last):
File "/usr/share/qgis/python/plugins/processing/core/GeoAlgorithm.py", line 203, in execute
self.processAlgorithm(progress)
File "/home/jordan/.qgis2/python/plugins/qgis-swmm/SwmmAlgorithm.py", line 371, in processAlgorithm
total_size = os.path.getsize(outfilename)
File "/usr/lib/python2.7/genericpath.py", line 57, in getsize
return os.stat(filename).st_size
OSError: [Errno 2] No such file or directory: '/home/jordan/.qgis2//processing/outputs/swmm.out'

Now I have looked at the permissions for that folder and set all of them to anyone including on each of the executable files within the swmm folder. I have also tried running QGIS under sudo to see if that would work and it has not. I tried creating an empty swmm.out file and running the plugin and received empty output with this from the log
2017-04-16T00:58:13 0 /bin/sh: 1: /home/jordan/swmm: Permission denied

Obviously there is something in the permissions where it will create the swmm.inp file but when processing it has issues with creating and populating the swmm.out file, I am running this on Ubuntu 16.04 with QGIS 2.18.6

Producing the .inp file rather then running the swmm model

It seems like this plugin does most of what I would like to do in qgis, which is to produce the input file (.inp) from gis data. Running Swmm algorithms is not part of my aim, but disable that part from this plugin is beyond my capabilities.
Is it possible to create another icon only to run the part that produces the input file?

Setting up Qgis swmm

Hello everyone,

I've been trying to set up my qgis swmm plugin on windows, following the tutorial, but had no success. I'm using QGIS 2.18. This is what I've done so far:

  • Put the downloaded files into the QGIS plugin directory;
  • Using my pgAdmin 4, created a database called "swmm_test" and imported the example database into it.
  • Opened QGIS, started a new project, clicked on add postgis layer, configured a new connection to my database, and followed the rest of the instructions (although there was no "layers with geometry duplicated in the list).
  • After that, I opened the processing toolbox, double clicked on the icon Swmm - Simulation - Simulate and the following message appeared:

image

"This algorithm cannot be run" How do I configure swmm command line?

I went then to directory where the example files are, and saw that there is a qgis project in there, but could not open it, as it required a login and a password i dont have.

Can someone help me with this? I would appreciate a lot!

Thanks guys!

Control Rules using TIMEOPEN and TIMECLOSED

I have a tide gate that opens when the tide reaches a certain elevation and closes after two hours. I can open it based on the node depth, but there is no response when I try and close it using TIMEOPEN < 2.0.

What is the proper syntax to use to relate the conduit status (open or closed) to TIMEOPEN if the original control was based on node depth?

RULE GATELOGIC
IF NODE O2 DEPTH > 15
AND CONDUIT 015 TIMEOPEN < 2.0
THEN CONDUIT 015 STATUS = OPEN
ELSE CONDUIT 015 STATUS = CLOSED

swmm no output

I edit the SwmmAlgorythm.py with the same kind of changes that are in the commit:
Oslandia/qgis-epanet@be1b5c6

I run the example getting the following error:
[Error 2] Impossibile trovare il file specificato: u'C:\Users\pc04.qgis2\processing\outputs\swmm.out' See log for more details

I tried to create an empty file 'swmn.out' in \processing\outputs

The processing runs but output tables and vectors are empty

I'm running Qgis 2.14 on Windows7 64bit

Possible Collaboration with Open Water Analytics

Great initiative!

I wanted to reach out to your group and present a possible collaborative opportunity for a couple of projects we have going on at Open Water Analytics.

https://github.com/OpenWaterAnalytics/Stormwater-Management-Model
https://github.com/OpenWaterAnalytics/pyswmm

By interfacing directly with PySWMM, you might be able to allocate your resources on linking this to QGIS, directly. Which will be absolutely awesome!

We are collaborating with USEPA to extend functionality of SWMM. OpenWaterAnalytics is leading an open source development initiative for both SWMM and EPANET.

SWMM at Open Water Analytics

One of our larger projects has been adding an API to SWMM which will support initiatives like yours. The philosphy with this project is to work directly in SWMM's data model as opposed to duplicating it in another language.

int DLLEXPORT  swmm_getSimulationUnit(int type, int *value);
int DLLEXPORT  swmm_getSimulationAnalysisSetting(int type, int *value);
int DLLEXPORT  swmm_getSimulationParam(int type, double *value);

int DLLEXPORT  swmm_countObjects(int type, int *count);
int DLLEXPORT  swmm_getObjectId(int type, int index, char *id);

int DLLEXPORT  swmm_getNodeType(int index, int *Ntype);
int DLLEXPORT  swmm_getLinkType(int index, int *Ltype);

int DLLEXPORT  swmm_getLinkConnections(int index, int *Node1, int *Node2);
int DLLEXPORT  swmm_getSubcatchOutConnection(int index, int *type, int *Index );

//Nodes
int DLLEXPORT  swmm_getNodeParam(int index, int Param, double *value);
int DLLEXPORT  swmm_setNodeParam(int index, int Param, double value);
//Links
int DLLEXPORT  swmm_getLinkParam(int index, int Param, double *value);
int DLLEXPORT  swmm_setLinkParam(int index, int Param, double value);
int DLLEXPORT  swmm_getLinkDirection(int index, signed char *value);
//Subcatchments
int DLLEXPORT  swmm_getSubcatchParam(int index, int Param, double *value);
int DLLEXPORT  swmm_setSubcatchParam(int index, int Param, double value);
// 
int DLLEXPORT swmm_getSimulationDateTime(int timetype, int *year, int *month, int *day,
	int *hour, int *minute, int *seconds);
int DLLEXPORT  swmm_setSimulationDateTime(int timetype, char *dtimestr);

//-------------------------------
// Active Simulation Results API
//-------------------------------
int DLLEXPORT swmm_getCurrentDateTimeStr(char *dtimestr);

int DLLEXPORT swmm_getNodeStats(int index, TNodeStats *nodeStats);
int DLLEXPORT swmm_getStorageStats(int index, TStorageStats *storageStats);
int DLLEXPORT swmm_getOutfallStats(int index, TOutfallStats *outfallStats);
void DLLEXPORT swmm_freeOutfallStats(TOutfallStats *outfallStats);

int DLLEXPORT swmm_getLinkStats(int index, TLinkStats *linkStats);
int DLLEXPORT swmm_getPumpStats(int index, TPumpStats *pumpStats);

int DLLEXPORT swmm_getSubcatchStats(int index, TSubcatchStats *subcatchStats);

int DLLEXPORT swmm_getSystemRoutingStats(TRoutingTotals *routingTot);
int DLLEXPORT swmm_getSystemRunoffStats(TRunoffTotals *runoffTot);

//-------------------------------
// Setters API
//-------------------------------
int DLLEXPORT swmm_setLinkSetting(int index, double setting);
int DLLEXPORT swmm_setNodeInflow(int index, double flowrate);

PySWMM

Since it looks like this project has Python Roots, you might want to look into PySWMM: https://github.com/OpenWaterAnalytics/pyswmm

Error after running the simulation

Hi Vincent,

I have run the simulation. But the processing did not happen as there were errors written to the swmm.out log file which are as follows: AS per your suggestion am posting the error into the github as an open issue
ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 113 of [TIMESERIES] section:
INFLOW@82309 PyQt4.QtCore.QDateTime(1988, 1, 1, 0, 0) 0.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 114 of [TIMESERIES] section:
INFLOW@82309 PyQt4.QtCore.QDateTime(1988, 1, 1, 0, 15) 40.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 115 of [TIMESERIES] section:
INFLOW@82309 PyQt4.QtCore.QDateTime(1988, 1, 1, 3, 0) 40.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 116 of [TIMESERIES] section:
INFLOW@82309 PyQt4.QtCore.QDateTime(1988, 1, 1, 3, 15) 0.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 117 of [TIMESERIES] section:
INFLOW@82309 PyQt4.QtCore.QDateTime(1988, 1, 1, 12, 0) 0.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 118 of [TIMESERIES] section:
INFLOW@80408 PyQt4.QtCore.QDateTime(1988, 1, 1, 0, 0) 0.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 119 of [TIMESERIES] section:
INFLOW@80408 PyQt4.QtCore.QDateTime(1988, 1, 1, 0, 15) 45.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 120 of [TIMESERIES] section:
INFLOW@80408 PyQt4.QtCore.QDateTime(1988, 1, 1, 3, 0) 45.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 121 of [TIMESERIES] section:
INFLOW@80408 PyQt4.QtCore.QDateTime(1988, 1, 1, 3, 15) 0.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 122 of [TIMESERIES] section:
INFLOW@80408 PyQt4.QtCore.QDateTime(1988, 1, 1, 12, 0) 0.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 123 of [TIMESERIES] section:
INFLOW@81009 PyQt4.QtCore.QDateTime(1988, 1, 1, 0, 0) 0.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 124 of [TIMESERIES] section:
INFLOW@81009 PyQt4.QtCore.QDateTime(1988, 1, 1, 0, 15) 50.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 125 of [TIMESERIES] section:
INFLOW@81009 PyQt4.QtCore.QDateTime(1988, 1, 1, 3, 0) 50.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 126 of [TIMESERIES] section:
INFLOW@81009 PyQt4.QtCore.QDateTime(1988, 1, 1, 3, 15) 0.0

ERROR 211: invalid number PyQt4.QtCore.QDateTime(1988, at line 127 of [TIMESERIES] section:
INFLOW@81009 PyQt4.QtCore.QDateTime(1988, 1, 1, 12, 0) 0.0

Please kind guide me as to how to resolve the above issue. Would be highly grateful to you as I want to complete the end to end processing.

I got this error on execute the sample data

File "C:/Users/jorgealmerio/.qgis2/python/plugins\processing\core\GeoAlgorithm.py", line 244, in execute
unicode(e) + self.tr('\nSee log for more details'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 21: ordinal not in range(128)

Provide better use cases with sample data

It would be great to have better examples with qgis-swmm, so that users can get a grasp of it faster.

If someone has some sample data he could share and publish, do not hesitate to contact us here or at Oslandia.

SWMM broken plugin for QGis 2.8.6-wien

I installed the SWMM plugin following the readme instructions but the pluggin seems to be broken as see in the image I attached here.
Could you help me?
I am using Ubuntu 16.04, Qgis version 2.8.6-wien and SWMM 5.0.011
Thank You
Florencia Srur
Uploading Qgis_swmm.png…

Separate in 3 steps

This is issue is related to #14. For more flexibility, it might be interesting to have the possibility to lauch each step separately:

  1. Generate .inp
  2. Launch swmm
  3. Merge result with geometry

In this way, one would be able to run swmm with the GUI to change the input data and parameters.

QGIS 3

is anyone working on a version for QGIS 3?

qgis to swmm

i'm trying to use your plugin with qgis 3.12.2 but there are any missing content in the downloaded file. i need a procedure to import in swmm 5.1 from a qgis' shape file. i hope you can send me a solution.
thanks

Valerio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.