0% found this document useful (0 votes)
3 views

qswatplus-tutorial

The document outlines the setup and features of QSWAT+, a QGIS plugin for the Soil and Water Assessment Tool (SWAT+), detailing objectives, installation steps, and new functionalities. It covers the process of creating a SWAT+ project, including watershed delineation, digital elevation map (DEM) loading, and defining project parameters. Additionally, it explains how to create floodplain and upslope landscape units for hydrological response units (HRUs) within the SWAT+ modeling framework.

Uploaded by

geoai.drm
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

qswatplus-tutorial

The document outlines the setup and features of QSWAT+, a QGIS plugin for the Soil and Water Assessment Tool (SWAT+), detailing objectives, installation steps, and new functionalities. It covers the process of creating a SWAT+ project, including watershed delineation, digital elevation map (DEM) loading, and defining project parameters. Additionally, it explains how to create floodplain and upslope landscape units for hydrological response units (HRUs) within the SWAT+ modeling framework.

Uploaded by

geoai.drm
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 75

QSWAT+

QGIS Interface for Soil and Water Assessment Tool (SWAT+)

http://swat.tamu.edu

Chris George
[email protected]
(Formerly) United Nations University
International Institute for Software Technology
Macao

1
Objectives

The objectives of this exercise are to

 set up a SWAT+ project using QSWAT+

 become familiar with the capabilities of QSWAT+.

2
New features since QSWAT

 Environment: QGIS 3, 64-bit, SQLite, Windows and Linux, all open source
 Streams + channels: HRUs more precisely placed
 Landscape units: floodplain + upslope
 Lakes
 Ponds and reservoirs: can generate automatically

3
Setting up QSWAT+

QSWAT+ is a plug-in for the QGIS (http://www.qgis.org) GIS system. To set up QSWAT+:

 Download QGIS (http://qgis.org/downloads/QGIS-OSGeo4W-3.4.9-1-Setup-x86_64.exe). Note that


currently this must be QGIS 3, not QGIS 2, a 64-bit version, and we recommend using the current long
term release since that is what we test against. If you already have a 32-bit version of QGIS installed do
not worry - you can install a second version and run both.
A Linux version will be available soon.

 Get the SWAT+ installer (https://swatplus.gitbook.io/docs/installation) and install it with the default settings.
This supplies QSWAT+, the SWAT+ editor and the SWAT+ program.
QSWAT+ can be installed for yourself only or everyone. For everyone requires administrator privileges,
and will need redoing if you upgrade QGIS, so choose yourself only as default.
Optionally, you can also get a global weather generator (useful for everyone) and a SSURGO/STATSGO
soil database (useful if your project is in the USA).

4
Installing the QSWAT+ plugin
 You need to set QGIS to load the QSWAT+ plugin. To do this use the Plugins menu and select Manage
and Install Plugins .... Select All, scroll down to QSWAT3_64, and check it (Figure 1). Close the Plugins
form. You will see a SWAT+ button in the QGIS toolbar, which you will use to start QSWAT+.

Figure 1: Installing the QSWAT+ plugin

5
QSWAT+ setup

 Click the SWAT+ button in the toolbar to get the main QSWAT+ form (Figure 2):

Figure 2: QSWAT+ main form and about form

 Click the About button to get some information about versions of QSWAT+, QGIS, and Python.

6
QSWAT+ parameters

 Click the QSWAT+ parameters button

Figure 3: QSWAT+ parameters

 If you installed the SWAT+ Editor and datasets somewhere other than the default directory, you can
change it.

7
 MPI is the Message Passing Interface which QSWAT+ can use for watershed delineation. It is not
essential, and if you don't want to install it you can uncheck Use MPI. If you have a multi-core processor
and you have large digital elevation maps it is probably worth installing, and you can use this form to
define where its Bin directory is. For more details on installing it see the QSWAT+ user manual.
 There are a number of other parameters you can set, mostly for fine tuning your model, and beyond the
scope of this introduction.
 If you have changed anything, click Save, else Cancel.

8
Starting a new project
 In the main QSWAT+ form click New Project. This produces a form for selecting a parent directory for the
new project. In Figure 4 we are about to select Robit. After selecting the parent directory a small form
appears asking for a project name. Type in Demo and click Save.

Figure 4: Selecting project location

9
Project structure
 When a project is created we get project directory, in our case Robit\Demo, and in it a project file, in our
case Demo.qgs, a project database in our case Demo.sqlite, and a reference database
swatplus_datasets.sqlite. It also contains some subdirectories: (Figure 5).

o Scenarios will be used by the SWAT+ Editor and SWAT+


o Watershed will contain the rasters we use or create in Rasters, the shape files we use or create in
Shapes, and some reports in Text.

10
Figure 5: Project directories

 Any input maps you provide are copied into the project structure. This means you will not lose the
originals if you delete a project. It also means you can move or copy the whole project to another location,
or another machine, simply by moving or copying the project file and project directory.

11
The project database

 If you look in the Demo directory you will find an SQLITE database Demo.sqlite. This is a copy of a default
project database stored as C:\SWAT\SWATPlus\Databases\QSWATProj2018.sqlite.
 The project database will be used later by the SWAT+ Editor. QSWAT+'s purpose is to create the tables
based on GIS data extracted from the project's maps that are needed by the SWAT+ Editor.
 Our example is a watershed draining into Lake Tana in Ethiopia, which we call Robit. The data is supplied
with SWAT+ and is stored in C:\SWAT\SWATPlus\ExampleDatasets in a directory Robit. You will be
accessing this Robit directory frequently, so I suggest you pin it to your Quick access list. (Right click in
Windows explorer and select Pin to Quick access.) I will call it Robit.

12
Watershed delineation
 We are now ready to take the first step in running QSWAT+. Our main form indicates that we will first
Delineate Watershed (Figure 6). Click this button to open the watershed delineation form.

Figure 6: Ready to delineate watershed

 The purpose of watershed delineation is to identify


 where the streams and channels will run
 which parts of the area will drain into which reaches of the streams: these are subbasins
 (optionally) which parts of the area are classified as floodplain or upslope.
 A reach of a stream is a portion between two stream junctions, or from a source to a junction, or from a
junction to the main outlet.
13
Watershed delineation form

Figure 7: Watershed delineation form

14
Digital elevation maps

 The first task in watershed delineation is to load a digital elevation map (DEM).

 Digital elevation maps are grids (also called rasters) in which the value at each point is the elevation
(height above sea level), commonly in metres.

 QSWAT+ accepts a wide range of grid formats, in fact any format acceptable by the Geospatial Data
Abstraction Library (GDAL)

 QSWAT+ uses TauDEM (http://hydrology.usu.edu/taudem/taudem5/) to do the watershed delineation, and


TauDEM requires GeoTiff format DEMs. So if necessary QSWAT+ does a conversion to GeoTiff when it
copies the DEM into the project.

 Watershed delineation, and later modeling by SWAT+, assumes that each cell in the DEM grid represents
the same area. So the DEM needs to be projected into, for example, UTM. (UTM is not exactly an equal
area projection, but is close enough for most purposes.) So if your DEM is in lat-long projection you will
need to use the tools of QGIS to reproject it before you use it in QSWAT+. (Use the menu item Raster,
then select Projections and Warp (Reproject).)

15
Selecting a DEM
 Click the Select DEM button to open the Select DEM form, and navigate to Robit\DEM.
 In this example we have an ESRI grid, which is stored in its own directory srtm_30m .
 The GDAL convention for ESRI grids is to select the hdr.adf file as the one to load. (Pull down the list
currently set to All files to see the conventions for other grid formats.) Select hdr.adf and click Open.

Figure 8: Selecting the DEM

16
DEM load and display

 As the DEM is converted to GeoTiff you may briefly see the shell window where GDAL is working. Then
the DEM is displayed in QGIS
 A Hillshade layer is also created to give a better impression of the terrain.

Figure 9: DEM loaded

17
DEM properties
 If you select the DEM properties tab in the Watershed Delineation form you can see information on the
horizontal and vertical units, the cell size, the area of a cell, the extent, and the projection. If your DEM
has vertical units other than metres this is the time to select the units.

Figure 10: DEM properties

18
Setting the thresholds

 Return to the Delineate watershed tab.

 There is an option to burn in an existing stream network. This is useful (when you have a suitable map to
use) and all or part of your area is relatively flat. It lowers the DEM elevations along the streams so that
delineation can find them. We have one for this example: check Burn in existing stream network and
navigate to Robit\RobitStreams\robReach.shp. Click Open. This file is added to the map canvas.

 Delineation needs a number representing the minimum area needed to form a stream and to form a
channel. These can be defined as either a number of cells or as an area, and you can choose the units to
use for an area.

 Default values are already provided. You can use these, create the channels and streams, change them
and create them again, until what you get looks reasonable. We will change the units to hectares, and put
9 ha as the area for a channel and 90 ha for a stream. The number of cells changes to 100 and 1000 (as
the DEM cells are 30 metres square.)

Figure 11: Defining the channel and stream formation thresholds

19
TauDEM options

 Before starting delineation, we can set a couple of options for TauDEM.

 The Number of processes option sets the number of processes to use if we are using MPI. If we don't
have MPI, or if we have it but for some reason do not wish to use it, this number should be set to 0.

 To use MPI, set it to some positive value. On a dual core processor 8 seems to be a good choice, and on
a quad core processor 12 or more is. Feel free to experiment.

 A series of TauDEM tools will be run to do delineation. You can see their outputs either after you have run
them, by selecting the Taudem output tab, or as they are run by checking Show Taudem output .

 Delineation can take some time, so be patient!

Figure 12: TauDEM options

20
Channel and stream definition
 Click Create streams.
 A series of TauDEM tools are run: PitRemove, D8FlowDir, DInfFlowDir, Area D8, AreaDinf, GridNet,
Threshold, and StreamNet. You can examine their output in the Taudem output tab if you wish.
 The channel and stream reach network is added to QGIS.

Figure 13: Channels and streams created

21
Defining outlets

 We normally define at least a main outlet for our watershed. It is also possible to define:
o inlets, which we use if we want to model a large watershed in sections. QSWAT+ will exclude the
area upstream from an inlet from its model.
o upstream outlets, where SWAT+ will produce data, so we place these where we have measured
data
o reservoirs and ponds
o point sources
 You can define main outlets on more than one part of the stream network, to model the watershed in more
than one piece. An outlet is 'main' if it has no outlet downstream from it.
 If you don't use an inlets/outlets shapefile (also called a vector file), main outlets will be defined where the
streams cross the edges of the DEM.
 Each inlet or outlet point you define will create a subbasin boundary, because it will define the end of a
stream reach. Each reservoir, pond or point source you define will divide its channel into two channels.
 It is possible to define points by using an existing shapefile or by drawing them interactively. Drawing them
interactively will create a shapefile which we would use in future runs on the same project.
 It is also possible to draw on an existing shapefile to create additional points, or to select only a subset of
points in an existing shapefile.

22
 All inlet or outlet points must be placed on a stream, and others on a channel, so if we want to do any
drawing we need to display the channel and stream network.
 If we are using an existing inlets/outlets shapefile without alteration we need not click on the Create
streams button, but go straight to Create watershed.

Drawing points

 We have a prepared outlet point file for this example, but first we illustrate how to draw points.
 Make sure that Use an inlets/outlets shapefile is checked, and click on Draw inlets/outlets.
 The Inlets/outlets form appears. Make sure that Outlet is selected, and click on the map around 328500,
1289500 Try to get the point on the stream. Click OK.

23
Figure 14: Drawing the outlet

24
Snap threshold

 If you zoom in you can see the point is almost certainly not exactly on the stream.
 QSWAT+ will snap (move) points to the nearest channel or stream provided they are within the snap
threshold, which defaults to 300 metres.
 When we create the watershed, the form will say how many points were snapped. If this is less than
intended we can use QGIS to move them closer, or just try increasing the threshold. If we have several
points and some were not snapped, the Review snapped will show which have been snapped
successfully.
 We will use an existing file containing our outlet. Right click on the Drawn inlets/outlets item in the Layers
panel, and select Remove.
 Click the button on the right of the Watershed Delineation form showing the inlets/outlets file, navigate to
Robit\MainOutlet\MainOutlet.shp and Open.
 Click Create watershed, and check that 1 snapped is reported on the Watershed Delineation form.

25
Watershed creation
 Watershed creation reruns some TauDEM programs (AreaD8, GridNet, Threshold, StreamNet) and then
produces and displays the watershed shapefile, showing the subbasin boundaries.

Figure 15: Watershed created

26
Creating floodplain and upslope

 There is an option to distinguish between floodplain and upslope areas. This can help place the
hydrological response units, (HRUs) the basic building blocks of SWAT+ models. Each HRU will drain to
its landscape unit. If we create floodplain and upslope landscape units then each channel will have two,
one floodplain and one upslope, otherwise each channel will have a single landscape unit.
 Make sure the Create landscape tab is selected, and click Create to open the Landscape analysis form
(Figure 16)

Figure 16: Creating floodplain

27
 There are three methods of creating floodplains: buffering channels, DEM inversion, and branch length
calculation.

o Buffering channels is a simple method of creating a strip either side of the channel that is a multiple
of its width (which QSWAT+ estimates from the area draining into it)

o DEM inversion involves finding ridges by, effectively turning the DEM inside out and finding ridges as
if they were streams. The floodplain consists of those points for which the ratio of a point's height
above the stream to the ridge's height above the stream is at most the slope position threshold,
which defaults to 0.1.

o Branch length defines ridge points as those for which the length of flow path for an adjacent point to
where the flow paths of the two points meet exceeds a threshold. It then uses slope position like
DEM inversion.

Branch length typically gives similar results to DEM inversion, but is perhaps an order of magnitude slower
to compute.

 Generate a floodplain map using DEM inversion, with default thresholds (Figure 17).

 You can generate several floodplain maps, with different methods and/or thresholds, and later select the
one you think most appropriate.

28
Figure 17: Floodplain by inversion

29
Merging subbasins

 Delineation often produces very small subbasins where there are small distances between stream
junctions. These can distort SWAT+ results and it is a good idea to remove them.
 Select the Merge subbasins tab click Select subbasins, and on the Select subbasins for merging form
that appears check Select small subbasins.

Figure 18: Merging subbasins

30
Merging subbasins

 Click Select and the form says that 1 subbasin is selected. Click Save.
 The map canvas shows the selected subbasin in yellow: it is the one nearest the outlet. This one cannot in
fact be merged, for two reasons. First, merging is with the subbasin downstream, and there is no such
subbasin, since we are at the main outlet. Second, it is not allowed to merge a subbasin if it has an inlet or
outlet, because that point would cease to be on a subbasin boundary.
 Click the Merge button and the failure is reported. Click OK.
 If you wish, try following the instructions on the subbasin selection for merging form, click Select, Save,
and Merge to see the effect. Then click Create watershed again to restore the original subbasins.

31
Adding lakes

 Lakes (which may form either ponds or reservoirs) can be added in the form of shapefiles.
 We will not be defining any lakes: see the QSWAT+ user manual for details.

32
Delineation Complete

 We see that the subbasins have now been numbered, and these are the numbers used in the SWAT+
inputs and outputs.

 Select the Subbasins entry in the Layers panel and use the Zoom to layer button to get the view in Figure
19.

33
Figure 19: Delineation complete

34
HRU definition

SWAT+ uses subdivisions of landscape units (LSUs) called hydrological response units (HRUs). Each HRU is a
particular combination of LSU, landuse, soil, and (optionally) slope range. We have identified our subbasins, so
the next step is to add landuse and soil information. Our main form shows that Step 1: Delineate Watershed is
Done (Figure 20). We click Step 2: Create HRUs and we get a new form: Create HRUs.

Figure 20: Ready to create HRUs

35
Adding landuse and soil data

 To select the landuse map, we click on the button to get the Select landuses file form. In this case it is
again an ESRI grid and so we navigate to Robit\Landuse\roblandusenew and select the hdr.adf file.
There is no need to change the grid format, so it is copied in the same ESRI grid format into our
Source\Landuse directory and added as a layer. Similarly we select the soil map, also an ESRI grid, from
Robit\Soil\mowr_soil90. The soil map is clipped because it is much larger than the DEM.

 The landuse and soil maps are just grids of numbers. We have to relate these numbers to landuse codes
and soil names, which we do by defining lookup tables in the project database. We can define these
tables before we start, but for lookup tables there is an option to import comma-separated value (csv) files.
In the pull-down menus for Landuse table select Use csv file. Navigate to Robit and select
Robit_landuses.csv. A table called Robit_landuses is created in the project database and appears as the
Landuse table. Next time we run the project it will be available and selected when we start this form: we
only need to read the csv file once (though we can change it and import it again).

 Similarly, import Robit\Robit_soils.csv to make the soil lookup table Robit_soils.

 Lookup tables for landuses:


o have landuse in their names
o map LANDUSE_ID values (values found in the landuse map you will use) to SWAT_CODE values
(SWAT+ landuse codes, found in the crop or urban table in the reference database)

36
 Lookup tables for soils:
o have soil in their names
o map SOIL_ID values (values found in the soil map you will use) to SNAM values (soil names found
in the usersoil table in the reference database

 We also need a table of soil properties, called a usersoil table. Import Robit\Robit_usersoil.csv to create
Robit_usersoil as the Usersoil table.

37
Creating potential HRUs

 We can divide HRUs also according to slope bands. We want to create the slope bands 0 – 10, and 10
upwards, where the numbers are percentages. To do this type 10 in the Set bands for slope box and click
Insert. See [0, 10, 9999] in the Slope bands box. You can insert as many intermediate points as you wish
by repeating the procedure. Use Clear to start again.

 We can also at this point define elevation bands. These are bands used for subbasins at high elevation
affected by snow and ice. You set them by defining a minimum elevation: only subbasins whose maximum
elevation exceeds this are given slope bands, and by defining how many bands to use. We do not need
them for this example.

 There is an option to Generate FullHRUs shapefile. Check it. We will discuss the result later.

 There is a pull-down menu Select floodplain map (optional). Use it to select the floodplain map by
inversion we made earlier.

 The Read choice is set to Read from maps and is currently the only choice. In future runs of the example,
provided we don't change the watershed delineation, the soil and landuse files, or the slope bands, we will
be able to Read from previous run. This reads data stored in the project database and is much faster than
rereading the maps.

38
 Click Read. This will read data about the subbasins, LSUs and slopes from watershed delineation, plus
landuse and soil data, and can take some time, especially if generating a FullHRUs shapefile, so be
patient!

 When the rasters are all read and the full (or potential) HRUs created, the form reports that there are 9
subbasins, 87 channels, and 516 potential HRUs.

39
Potential HRUs created

 At this point we can see in the Layers panel


o a Full LSUs map has been added showing the LSU boundaries
o the landuse and soil maps are loaded and labelled with landuse codes and soil names
o a slope bands map has been created and coloured according to slope bands

 If you want to examine these layers, cancel the rendering (visibility) of the layers above them.

 Each cell in the watershed has been categorised according to


o the LSU it is in
o its landuse
o its soil
o (if we defined slope bands) its slope band

 Points which share the same four values are grouped into potential HRUs: potential because we usually
decide to remove some because they are small and can be ignored in the SWAT+ model.

40
Examining potential HRUs

 We can use the Full HRUs shapefile to see our potential HRUs. Select Full HRUs entry in the Layers
panel, right click on the entry, and select Open Attribute Table. Click on the left of entry number 305 to
select it, and zoom into the area of the map canvas that has turned yellow.

41
 The cells marked in yellow share
o subbasin 8
o channel 48
o landscape upslope
o landuse AGRL
o soil LVx
o slope band zero to 10
 Collectively they have an area of 9.09 ha, and comprise 4.6% of subbasin 8, 62.3% of the upslope LSU of
this channel. If this potential HRU is retained, these cells will be treated as a single unit draining into the
upslope LSU and thence into the floodplain LSU and so into channel 48.

Merging channels
 Channels with small LSUs (typically short channels) generate HRUs that contribute strongly to the
processing time of SWAT+ but make little difference to the results, and so it is common to merge them.
 There are typically many channels (we have 87 in a small watershed), so this is an automatic process
rather than a manual one.
 Set the threshold to 2% of the subbasin, and click Read again. We see the channel count reduces from 87
to 72, and the potential HRUs from 516 to 455.
 You can change the threshold and repeat the merge as many times as you like.

42
Splitting and exempting landuses

 We have two further options now available in the Create HRUs form: Split landuses and Exempt landuses.

 Splitting landuses allows us to divide existing landuses.


Suppose, for example, we know that 50% of the landuse AGRL
(generic agriculture) in this area is actually CORN and 50% is
TEFF. Then we could use the Split Landuses form as illustrated .
Do this and save the split.

 Exempting landuses
means marking them as not
to be removed when we
come later to remove small
HRUs. For example, the
FRST (forest) landuse could
be exempted. Make this
exemption.

43
Ponds and reservoirs
 Ponds and reservoirs may be added in 3 ways:
 By adding lakes
 By adding pond or reservoir points to the inlets/outlets shapefile in watershed delineation. These
points will be snapped to channels, and will divide channels in two.
Areas of landuse WATR in the adjacent LSU of the upper channel will be allocated to the pond or
reservoir. (The adjacent LSU is the floodplain if used, else the channel's single LSU.) Users are
warned if there is no such WATR area.
 By setting the Reservoir threshold, which is the percentage of landuse WATR in the adjacent LSU of
each channel needed to form a reservoir. For example, if this is set to 20%, then any channel for
which landuse WATR is 20% or more of the adjacent LSU will become a reservoir. If the
downstream channel is also a reservoir by this method, they are combined into a single reservoir.
The default is 101%, effectively turning this mechanism off.

 Otherwise, area of landuse WATR form HRUs.

44
Reports
 If we look at the main MWSWAT form we see that two reports are now available: Elevation and Landuse
and Soil . Each can be opened by selecting it in the pull-down menu.

 The Elevation report shows the area and percentage distribution of elevation for the whole watershed and
for each subbasin:

Figure 21: Elevation report (fragment)

45
 The Landuse and Soil report shows the area and percentage distribution of each landuse, soil, and slope
band for the whole basin and for each subbasin.

Figure 22: Landuse and Soil report (fragment)

46
HRU Selection

 Subdividing the watershed into areas having unique land use, soil and slope combinations enables the
model to reflect differences in evapotranspiration for various crops and soils. Runoff is predicted separately
for each HRU and routed to obtain the total runoff for the watershed. This increases accuracy and gives a
much better physical description of the water balance.

 The user has a choice between making each LSU into just one HRU or dividing it
into multiple HRUs through the Single/Multiple HRUs selection.

 The first two choices define just one HRU for each LSU: single choices:
o Dominant HRU will choose the landuse, soil and slope combination of the
largest potential HRU in the LSU.
o Dominant landuse, soil, slope will give to the single HRU the landuse with the largest area of the
LSU’s landuses, and similarly for soil and slope.

 The other three choices are multiple choices. If one of these are chosen it is
possible to reduce the number of HRUs by eliminating small ones and redistributing their area
proportionately amongst the larger ones. Small ones may be determined in various ways:
o by thresholds for landuse, soil, and slope bands
o by area thresholds
o by targeting the number of HRUs to be formed

47
Filtering by area
 If Filter by area is chosen there is then a choice of threshold method, and a choice of threshold value.

o If the method chosen is Percent of landscape unit and the value (set by moving the slider or typing in
the box) is, say, 10, then HRUs which are less than 10% of their LSUs will be removed.

o If the method chosen is Area (ha) and the value set is, say, 5, then HRUs which are less than 5 ha
will be removed.

 The percent or area method makes a difference when subbasins vary considerably in size. Suppose, for
example, that LSU A has a size of 50 hectares and LSU B has a size of 5 hectares. Suppose potential
HRU A1 has a size of 5 hectares, and so is 10% of its LSU, and potential HRU B1 has a size of 2.5
hectares, and so is 50% of its LSU. Then when selecting by area, A1 is bigger than B1, but by percent B1
is bigger than A1. With the limits shown above, A1 would (just) be retained by both. B1 would easily be
retained by percent but eliminated by area.

48
Setting a target
 If Target number of HRUs is chosen there is then a choice of threshold method, and a choice of target
value. Suppose, for example, we set a target of 250 HRUs, out of the current 455.

o If the method chosen is Percent of subbasin then the HRUs will be sorted in order of their
percentages of their subbasins, and the smallest 155 will be eliminated.
o If the method chosen is Area (ha) then the HRUs will be sorted in order of their areas in hectares,
and the smallest 155 will be eliminated.

 Targets are typically exceeded when exemptions for some landuses have been chosen, or landuses are
split, as splitting is done after elimination. If the result has too many HRUs you can always run again with
a lower target.

49
Filtering by landuse, soil and slope

 We will use Filter by landuse, soil, slope. Select this option, and choose Percent of subbasin as the
method.

 We will first set the landuse percentage to 10 and click Go. This means for each LSU we will not
include any landuse for which the percentage area in the LSU is less than 10. The number 51 at the
end of the landuse slider indicates that this is the lowest percentage for a dominant landuse across all
the LSUs. Trying to set the percentage higher than this would mean trying to remove all HRUs from at
least one LSU.
 We set the same percentage of 10 for soil and click Go, and also for slope . Then we complete the
HRU selection by clicking Create HRUs. The form closes, and we are informed that we have selected
651 HRUs in the 9 subbasins.

50
HRUs report
 We see in the main QSWAT+ form, under Select report to view, that there is a new report available: HRUs
(see Figure 23).

 This shows the detailed actual and percentage areas for the watershed and each subbasin, for each
landuse and soil, before and after HRU creation, and for each HRU.

 If you want to change the HRU selection, click on Create HRUs in the main QSWAT+ form to reopen the
Create HRUs form. Read choice will be set to Read from previous run, and you can click Read and redo
HRU selection.

Actual HRUs

 If you chose (as we did) to create a Full HRUs shapefile you will see that a new shapefile Actual HRUs has
been created. This is simply the Full HRUs file with the eliminated HRUs removed.
 It appears from the Actual HRUs file that there are now holes in the watershed. But in fact the retained
HRUs have been proportionately increased in size so that in each subbasin their total area is the area of
the subbasin. This can be seen from the before/after figures in the HRUs report.

51
Figure 23: HRUs report (fragment)

52
Visualisation

 If we look at the main QSWAT+ form we will see a new button has appeared: Visualise. This becomes
available when there is an output database in the Default/Results directory (so it will reappear if you close
and reopen the project).

 Visualisation offers a number of ways to visualise SWAT+ outputs.

 Click Visualise to open the Visualise Results form (Figure 24).

 We have only one Scenario, the one called Default that the SWAT+ editor generates. If we copied this to
make a new scenario, we would place it in the Scenarios directory and it would appear in the Choose
scenario pull-down menu.

 The output tables available are the ones we saved, restricted to those that can be visualised.

 The period defaults to the period we chose, less the warm-up period (NYSKIP) of 3 years.

 There are three options available:

o Static data to display a summary value (such as a mean or a maximum) across the simulation for a
SWAT+ output.

o Animation to make an animated display of an output variable, showing how it changes with time.

o Plot to make graphical plots of SWAT+ outputs.

o Post processing which helps us calculate a number of environmental flows.


53
 There is also a Print section we will use to compose print layouts.

54
Figure 24: Visualise Results form

55
Visualising Static Data

 Select the Static data tab, and the lsunit_pw_mon output table. This generates a default results shapefile,
named <table>results.shp in the Results directory of the current scenario, namely Default. You can
change the file name and/or location if you wish. It is a copy of the lsus shapefile in the same directory.
 Under Choose variables the pull-down menu contains all the outputs in the lsunit_pw_mon table. You can
select all of them, by clicking All, or select them one at a time using Add. It does little harm to select All, so
we do this.
 We need to select a variable to display. Select bioms.
 We need to select a summary. Here
o Totals means, for each subbasin, a total value across the simulation
o Daily, Monthly, and Annual means are averages: the total figure divided by the number of days,
months, or years respectively in the simulation.
o Maxima and Minima are the maximum or minimum values of the variable in the simulation.
 Select Monthly means and click Create. The results shapefile is added to the map canvas (Figure 25).
 You can change the variable to display (select another one and click Create) or the summary (select
another one and click Create).
 You can examine the data being displayed by opening the attribute table of the results shapefile (right click
on its entry in the Layers pane).
 You can create and display new data as a function of existing data using QGIS Field Calculator.
56
Figure 25: Displaying static data

57
Printing
 QSWAT+ provides templates to create a composition of 1, 2, 3, 4 or 6 results maps laid out in either
landscape or portrait mode.

 The templates are not expected to provide final compositions. You can edit them to change text, change
the size and position of maps, etc.

 Each template includes as well as the maps and legends:


o Page title
o North arrow
o Scale bar
o Text box containing Author/Company
o Date

 We' ll make a 3-map display:


o Switch to the lsunit_ls_aa table and create the sedorgn map

 Switch to the channel_sdmorph_mon table and create the maximum peakr map. Remove the
visibility of the other two results maps to see this one clearly.
o Select Portrait and 3 as the number of maps, and click Print.
 After any editing, save it as a .pdf (Composer -> Export as PDF) or image (Composer -> Export as Image)

58
Figure 26: Print composition

59
Rules for creating print layouts

 If n maps are requested, the first n maps in the Results group of the Layers panel are used, regardless of
current visibility.
 Layers in the Watershed group are included as background if they are currently visible. The Watershed
layer is commonly used to provide subbasin boundaries. Results layers have transparency set to 35% so
that background layers are visible.
 If you want to include, for example, a landuse map, drag it into the Results group before clicking Print.
 The map layers in the composition are set locked: otherwise they would only show whatever the canvas
shows, but they can still be resized or moved.
 The scale bar is attached to the top left map. If you change its size the scale bar will adjust, but you need
to change the others manually to match.
 Hint: maximize the watershed size in the map canvas before you start to set up the composition.
 The composer has many features. Look at:
o https://docs.qgis.org/2.18/en/docs/user_manual/print_composer/print_composer.html
o http://www.qgistutorials.com/en/docs/3/making_a_map.html

60
Animation

 Select the Animation tab. Keep the output table as channel_sdmorph_mon.

 There are two modes of animation: map canvas and print composer. We will use the map canvas.

 Select New in the Set up animation group.

 We can only select one variable at a time, since animation continuously rewrites a shapefile and we do not
want it to run too slowly. Select flo_out.

 QSWAT+ calculates suitable breaks using the Jenks natural breaks algorithm, and 5 classes. This
calculation involves all the flo_out values for all the channels for the whole period, and can take some
time.

 Set the speed to 5 and click on the arrow to start the simulation.

 You can pause with the pause button and rewind to the start.

 You can also drag the slider, or use the left and right arrow keys to step through the animation.

 At each point the map canvas shows the values of flo_out for each channel at the date shown above the
slider. We chose earlier to print monthly output, so the animation proceeds in monthly steps.

 Animation is done by changing the attribute values of a shapefile, rivs0.shp in this case, in the current
scenario's Results\Animation directory. You can save this file, but remember it only contains values for
the time point currently shown.
61
Figure 27: Map canvas animation

62
Recording
 Rewind the animation, by dragging or using the rewind button.
 Click the Start recording button, and click the arrow to run the animation again.
 When it reaches the end (or whenever you like) click Stop recording.
 Each step in the recording has been saved as a PNG file. When you stop recording the PNG files are
assembled into an animated GIF.
 After Stop recoding, clicking Play will play the animated GIF using whatever is the default tool on your
machine.
 The speed of the recording is according to the speed setting when Stop recording is clicked. It may play
faster than the animation itself, so you may want to remake it with a different speed setting.
 Stop recording also deletes the PNG files. . If you want to use them, e.g. to use Gimp to make a more
elaborate animation, pause the animation or wait for it to finish, do not click Stop recording, and find them
in Scenarios\Default\Results\Animation\Png.

63
Print animation

 If we want to animate more than one variable at once the map canvas is not very suitable as the
animations will overlay each other. So we can use a print composition.
 Keep the New setting (if you choose Current the next animation will replace the old one).
 Change the table to lsunit_wb_mon and select surq_gen as the variable.
 Select Print Composer as the Animation mode.
 Select Landscape and 2 as the number of maps. This selects the first 2 maps in the Animation group,
regardless of visibility.
 Move the slider by hand towards the end of the period, e.g. June 2000 to reduce the number of images.
 Click Start recording. A form explains that the composer will start, and you can modify it, but you must
then save it as AnimationTemplate.qpt in the Results folder of the Default scenario. Click OK and the
composer appears (Figure 28)

64
Figure 28: Animation print composer

65
 Make any changes you wish, e.g. inserting your name.
 Use Composer -> Save as Template to save it as
C:\QSWAT_Projects\Robit\Demo\Scenarios\Default\Results\AnimationTemplate.qpt
as instructed. Confirm overwriting, and Quit the print composer.
 The red start/stop button indicates that recording is ready to start. Click the play arrow.
 The composer is used to generate an image for each time step. When it finishes, click Stop recording.
 A message tells you where the recording is stored - as Videon.gif (n is a number) in Default\Results.
 Click Play to see the saved animation.

66
Plotting Results

 Select the Plot tab.

 We are going to produce a graph of one or more variables against time. We might for example

o compare the same variables from different LSUs, channels or HRUs

o compare the same variables from different scenarios

o compare simulated variables to observed values

 We are going to compare simulated output from our main outlet with observed data which we have.

 Choose our observed data file, which is Robit\Observed\observedFlow.csv.

 Set the output table to channel_sdmorph_mon.

 Click Add plot to create a plot entry. We see that the scenario and table are selected, and Unit is not set.
The units will be channels, as we can see from the table name. Set the unit to 1, which we can see from
the map canvas is our main outlet's channel.

 Set the variable to flo_out.

 If we had a different run in another scenario, and wanted to compare, we would now use Copy plot, which
copies most of the entry above, change the scenario (top of the form), and change the channel to 1; it was

67
cleared because the other scenario might have had different channels. Note the way that changing one of
the pull-down menus changes the currently selected plot entry. Remove the extra entry with Delete plot.

 Click Add observed to add an entry from our observed data file. It uses observed as the name of the
scenario and allows us to choose the data column from those in the file. In this case there is only one,
Flow, and so it is preselected.

 Click Plot. We are first asked to provide a name for the output file, which will be a comma separated value
file. Such a file is created so that you can afterwards use other tools to display or analyse it. Choose a
suitable name, perhaps flow, and Save.

 You will get an error saying the data for 1998/1 is missing for the second plot, the observed one. Our
observed data only runs from January 1993 to December 1997. Change the year of the finish date to 1997
(Figure 29), and click Plot. Choose the same output file name, and confirm you are happy to overwrite it.

68
Figure 29: Plotting outputs and observed data

69
 SWATGraph will be opened, showing a line plot of the data (Figure 30).

 The data used is also displayed.

 Correlation is automatically calculated between all pairs of plots, and Nash-Sutcliffe Efficiency is calculated
for pairs involving an observed plot.

 You can change the histogram display to line using Chart Type and Update.

 You can pan and zoom to examine parts of the graph in more detail.

 You can save the plot as an image file for use in documents.

70
 You can provide a title, label the axes (click graph symbol).

Figure 30: SWATGraph

71
Observed data

 Observed data is essentially a comma-separated-value file with


 Headings on the first line, separated by commas
 As many data values as there are headings on each succeeding line, separated by commas
 As many data lines as there are dates in the SWAT+ output.

 If the first heading is DATE (or date, Date, or the same 4 letters in any cases) then the first column is
ignored. It is assumed (and not checked) that the dates correspond to the dates in the SWAT+ output.

 Leave blank for missing data, or put any text which cannot be parsed as a number, e.g. 'missing'. Missing
data will be omitted from graph.

72
Environmental flows
 QSWAT+ can calculate a number of environmental flows.
 They require channel_sd_day to have been chosen for printing.
 Select the Post processing tab in the Visualise Results form.
1. Qq provides for each calendar month the flow in m³/s that is exceeded by q% of the flows in that
month. For example, if you set q to be 95%, and set the subbasin to 7, and the August result is 0.03,
then 95% of the time the average daily flow from subbasin 7 in August is at least 0.03 m³/s.
2. dQp provides a single flow statistic for a selected subbasin, where d is the number of days for
creating moving averages, p is a threshold percentage. Users also need to set a start month (which
should not be in a low flow period) , and choose between Percentile and Mean. The flow for each
year is calculated as the minimum of the moving average flows for that year. Then if Percentile is
selected, and p is, say, 95 and d is 21, then 21D95 will be calculated as the flow which is exceeded
for 95% of the flows for each year. If Mean is selected then 21Qm is calculated as the mean of the
flows for each year: d is ignored.
3. Qb,. The Basic Flow statistic provides an annual and also monthly statistics for a selected subbasin.
A rate of flow for each year is calculated as the minimum moving average for a year, where the
length of the moving average is chosen as the one that gives the highest rate of change between the
minimum and the previous moving average. The annual result is then the mean of these flows for
each year.
The values for each month are the annual result multiplied by the variation factor for the month. The
variation factor is calculated as the square root of a ratio, the ratio of mean daily flow for days in that
month to the minimum such figure for all months.
73
 Results can be saved, either in separate files or combined into a single file, allowing results of different
statistics and different parameters to be retained and compared.
 The Robit basin is much smaller than would normally be used for calculating environmental flows.

74
Restarting a Project

 Click OK in the main QSWAT+ form (which saves everything) and then Project -> Exit QGIS to close QGIS

 Start QGIS again.

 It is possible to click the SWAT+ button and then use the Existing Project button, navigating to the project
(.qgs) file. But it is much more convenient to

o Use Recent Projects or Project -> Open Recent and select your project. This restores the map
layers.

o Click the SWAT+ button to start QSWAT+. This

 Tries to rerun delineation and HRU creation, and should succeed if they were previously
completed

 Creates a visualise button if a saved output database is discovered in


Scenarios/Default/Results.

 In this project, since it was previously run through completely, you are in a position to rerun any of

o Watershed delineation
o HRU creation
o SWAT+ Editor
o Visualisation.

75

You might also like