Skip to content

QGIS plugin for developing SWAT+ input data

Notifications You must be signed in to change notification settings

swat-model/QSWATPlus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QSWATPlus

QGIS plugin for creating inputs for SWAT+.

Build

The repository holds an Eclipse project. It was created on Windows but runs in Eclipse on Windows and Linux (Ubuntu at least) and Macs.

There is a Makefile that should provide enough information to build QSWATPlus.

Note that the only interesting projects in the Makefile are QSWATPlus, QSWATPlusLinux3_64 and QSWATPlusMac3_64. QSWATPlus3_32 is 32-bit for use with 32-bit Microsoft Office. QSWATPlus3_64 is only for 64-bit Microsoft Office and QGIS before 3.16.14 using Python 3.7. QSWATPlus3_9 is 64 bit, only for Windows QGIS using Python 3.9, and QSWATPlus3_12 is only for Windows QGIS using Python 3.12.

Build on Windows

64-bit QGIS Desktop does not include Python development files (Python.h and other header files, and python27.lib). So to compile the Cython files it is necessary to install the OSGeo4W Network Installer (64 bit):

  • download the installer osgeo4w-setup-x86_64.exe and run it
  • select Advanced Install
  • include the packages QGIS, GDAL and GRASS GIS (probably the default)
  • select Install from Internet
  • use the default root directory C:\OSGeo4W64, choose All Users if you have admin privileges, create icons if you wish
  • take default local package directory
  • use Direct Connection or as appropriate for your internet connection
  • choose a download site
  • in the Select Packages form you need to include qgis-ltr in the Desktop section with version at least 3.4.6
  • in the Select Packages form you need to include python devel in the Libs section
  • finish to install.

For the 32 bit version of QGIS you can use the standalone installer.

For both 32 and 64 bit QGIS you will need to add the cython package. To do this, run OSGeo4W.bat in the top QGIS directory as administrator. (Find it in Windows Explorer and right click to get Run as administrator) Then use the command pip install cython. If you get a message Fatal error in launcher: Unable to create process using '"' then use the command python -m pip install cython.

The compilation of the cython files generates some warnings that you can ignore.

You also need to install Microsoft's Visual C++ for Python. Download this (VCForPython27.msi) but instead of just running it immediately (which would install it under your home directory) start a command shell and use the command msixec /i pathtomsi ALLUSERS=1 where pathtomsi is the full path, e.g. C:\Users<user>\Downloads\VCForPython27.msi. Then it will install in C:\Program Files (x86)\Common Files\Microsoft. You will need administrator privileges to do this.

You also need to install MinGW. MinGW supplies the version of make we need, namely mingw32-make, and also the appropriate versions of utilities like mkdir. We assume it is installed in C:\Mingw.

Environment variables for Windows

The following need to be set to run make assuming VCforP is the path to Visual C++ for Python\9.0, e.g C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0

  • HOME: User's home directory
  • INCLUDE: VCforP\VC\Include;VCforP\WinSDK\Include
  • LIB: VCforP\VC\Lib\amd64;VCforP\WinSDK\Lib\x64 (64 bit) or VCforP\VC\Lib;VCforP\WinSDK\Lib (32 bit)
  • OSGEO4W_ROOT: Path to QGIS e.g. C:\OSgeo4W64
  • PATH: C:\MinGW\bin;C:\MinGW\msys\1.0\bin;VCforP\VC\bin\amd64;%OSGEO4W_ROOT%\bin (64 bit) or C:\MinGW\bin;C:\MinGW\msys\1.0\bin;VCforP\VC\bin;%OSGEO4W_ROOT%\bin (32 bit)
  • QSWAT_PROJECT: QSWATPlus

Build on Linux

The only environment variable required is QSWAT_PROJECT, set to QSWATPlusLinux3_64.

The project location for make in Eclipse is hard-wired to /media/sf_Public/QSWATPlus3. This was used since the QSWATPlus3 source directory was shared between Windows and a Linux virtual machine. Change this in Eclipse with Run -> External Tools -> External Tools Configuration and change Working Directory as appropriate for the make QSWATPlus3_64 and clean QSWATPlus3_64 programs.