You are on page 1of 13

Technische Universität München

Faculty of Civil, Geo and Environmental Engineering

Chair of Hydrology and River Basin Management

Prof. Dr.-Ing. Markus Disse

Hydrological and Environmental River Basin Modelling


Exercise Script

Master program Environmental Engineering


Technische Universität München
Dr. Ye Tuo

Winter Term 2020/21


1. Introduction

This script is a mutual effort of Jochen Scholtes, M.Sc., Susanne Haas, B.Sc., Axel Kasparek,
M.Sc., Dr. Zheng Duan, and Dr. Ye Tuo. The course ‘HERBM’ was first taught in the winter
term 2013 / 2014 and was created by Jochen Scholtes. This script therefore is still updated
and refined:

• It will be updated on a weekly basis during the course.

• You will have updated versions in in the CIP Pools in our lecture’s folder.

• You can print the current chapter when you need it (omit cover pages, etc.). In the end it
will only be necessary to reprint the first pages (cover, table of contents, etc.) and the last
pages, then you will have the entire document.

IMPORTANT!!!

SWAT/ArcSWAT is very sensitive to the language setting, so every time before you start
working on a project, please check the following steps:

• Change the Region settings through Control Panel to U.S.

• Change your keyboard to U.S., and make the U.S keyboard the default, otherwise the
keyboard will switch back to German from time to time.

• If you have GIS already running before applying these changes a restart might be necessary.
Once a SWAT run has terminated successfully, for data analysis the keyboard may be
changed to your usual settings.

Furthermore:

• If you use your own computer use the same versions of ArcGIS, ArcSWAT and SWATCup
as installed in the CIP Pool.

List of programs to be used in the exercises and downloading sources

• ArcGIS: The provided version is ArcGIS 10.6, but the latest version is 10.7. You are free to
choose one from them.

• ArcSWAT is freely available at:


http://swat.tamu.edu/software/arcswat/ . The provided version is ArcSWAT 2012.10.6.24
which is compatible for ArcGIS 10.6. You can download 10.7 version on the official website
if you are using ArcGIS 10.7.

• SWAT-CUP is available at (not free any more):


http://swat.tamu.edu/software/swat-cup/.
Free package of an old version is offered in CIP folder.

1
• SWAT Check is available at:
http://swat.tamu.edu/software/swat-check/.

• Matlab is available at:


http://www.in.tum.de/rbg/beschaffung/rahmenvertraege/matlab.html
The entrance to the Matlab is available through the portal: http://matlab.rbg.tum.de. For more
information on reference and activate the products you get after logging in with your TUM-
ID on the mentioned portal.

• QSWAT+ software is available at:


https://swat.tamu.edu/software/plus/.

2
2. Basic ArcGIS functions for hydrological applications
This chapter is set out to renew the students’ knowledge of GIS. We have chosen a sequence
of GIS functions (in the hydrology toolbox of ArcGIS) to delineate a watershed and
identify/define streams from a given digital elevation model (DEM).

When working with ArcSWAT, during the watershed delineation and stream definition steps,
ArcSWAT automatically calls a sequence of functions from the ArcGIS ArcToolbox:: Spatial
Analyst. As an exercise we are going to execute these steps by hand.

Startup

•Copy the data folder for this session from the respective (network-) folder to your Hard-
disk
\\nas.ads.mwn.de\tubv\cip\Lehre\LSHydrologie\HERBM_WS_20202021\ExerciseData\01_G
isRefresher
→ C:\HERBM\01_GisRefresher

• Open ArcGIS (ArcMap)


• Activate the Spatial Analyst for the ArcToolbox :
→ Customize → Extensions → activate Spatial Analyst
• To load data, right click on Layers → Add Data to load layers.
Click on the icon for Connect to Folder and connect to C:\HERBM
• Load the layer dem / dgm from the folder .\dem
• load the layer mask from the folder .\mask
• load the layer thann_pegelpunkt from the folder .\gauging_ station

Mask

For our processing we only need a small part of the whole DEM, so the first step is to reduce
the DEM’s extent by masking it. Use the following function:
• open the ArcToolbox : e.g. → Geoprocessing → ArcToolbox
• Click Spatial Analyst Tools → Extraction → Extract by Mask
• Choose Input raster (The input raster from which cells will be extracted.), Input raster
or feature mask data (Input mask data defining areas to extract.) and specify the Output
raster, e.g.:
C:\HERBM\01_GisRefresher\masked
• When you have extracted by mask uncheck the layers mask and dem to see the result

Fill it fills the sink


Besides an x,y coordinate, each pixel in the DEM has a z-value for its elevation. As a result of
the generation process of a DEM, some z-values can be wrong. Most often some z-values are
simply too low. In the DEM they artificially create potholes which influences further raster
analysis. In the GIS environment such pixels are called “sinks”, see Figure 2.1.

3
Figure 2.1: Scheme of a sink

In a preprocessing step we eliminate these sinks. Use the following function:


• Spatial Analyst Tools → Hydrology → Fill
–Input surface raster is masked (the DEM data you masked in the above step)
– Output surface raster, name it as filled

Compare with the data masked vs. filled, what differences do you notice?

if the water flows to east of the pixel it's given 2


Flow Direction

We determine the path that water would take if poured over the DEM. For each DEM pixel,
the height of the 8 surrounding pixels is analyzed. Water flow occurs along the steepest slope.
Use the following function:

• Spatial Analyst Tools → Hydrology → Flow Direction


–input is filled
–call the output as flowdir

Only 8 flow directions are allowed. The flow directions are indicated by specific values (1-
128), see the Figure 2.2. For example, the value 1 means that water flows to the East direction,
while 16 means to the West direction. The flow direction with values > 128 indicate an
erroneous raster processing, and this is most probably caused by non-filled sinks. This is why
the Fill function should be performed at the first to avoid this error!!!

guide

Figure 2.2: Scheme of Flow Direction; fill blanks by hand

4
counts the number of pixels that aaccumulate into a
particular pixel.
Flow Accumulation Upper bound - infin Lower bound - zero
Given the flow direction scheme, GIS determines a channel network. Use the following
function:
• Spatial Analyst Tools → Hydrology → Flow Accumulation
–input is flowdir
–call the output as flowacc

This function basically counts the pixels that drain into a pixel and assigns this value to that
pixel. A value of ‘Zero’ (lower bound) is assigned to all pixels that receive no inflow. The
upper bound is assigned to that pixel that receives inflow from most of the pixels in the area.

Set a Pour Point using this ArcGIS calculates the gauge point, it should be
In order to delineate a watershed you need to provide the basin outlet. From that GIS determines on the
the corresponding basin. Use the following function: stream.
• Spatial Analyst Tools → Hydrology → Snap Pour Point - also pretty
–Input is thann_pegelpunkt near to the
–A snap distance is used if the pour point does not exactly overlay the delineated stream real rain
network (enter a value if necessary). Choose an appropriate snap distance (e.g. 30 in gauge
map units) and check later whether your new pour point is on the stream network shown
by flowacc
–call the result pourpoint

Note that please make sure that the generated pourpoint is on the stream network shown by
flowacc, otherwise it cannot proceed for the following delineation of watershed.

Delineate watershed pourpoint and flow direction raster is needed


With the pour point (pourpoint) and a flow direction raster (flowdir), then we can extract the
watershed corresponding to our outlet. Within this catchment water eventually passes this Pour
Point to exit the basin. Use the following function:

• Spatial Analyst Tools → Hydrology → Watershed


–Inputs are flowdir and pourpoint
–call the output as wshed

Now we have our watershed. Finally, we can clip all layers processed so far to the extent of
this watershed. To speed up the process, use the batch mode.

• Spatial Analyst Tools → Extraction → Extract by Mask


• right click: → batch
–Input raster: masked, flowdir, flowacc
–Input raster or feature mask data: wshed
–Specify Output raster : folder and names, e.g. flowacc_wshed

Now everything is cut to the extent of our watershed. Finally, we can compare the stream
delineation of the ArcSWAT watershed delineation with our files. Therefore, we use the flow
accumulation raster.

5
first think of a threshold number(taken 300 here),if more than these pixels drain
into 1 pixel it will be called stream/channel pixel. Using this generate multiple
stream network, just to play around. Laso notice the green areas ive marked
here.
Generating a stream network raster file using the Raster Calculator

We can use the flow accumulation in combination with a threshold value to identify a stream
network. If the number of pixels draining into a certain pixel exceeds a certain threshold,
this pixel is classified as a stream pixel. The lower the threshold the more detailed the resulting
stream network (i.e. the more pixels are classified as stream network). The higher the threshold
the more generalized the stream network becomes.

For this analysis we use the Raster Calculator. The Raster Calculator allows for algebraic
operations on raster files, based on the values of the pixels. Moreover, control structures like
if-clauses can be executed.

• Go Customize → Customize mode → Commands


→ Show commands containing: typing raster calculator
• Drag and drop the symbol into your top command bar and click it to start the Raster
Calculator, see Figure 2.3 Conditional expression
• Implement an if-clause using the following command: Con("raster" > threshold, 1).
Note that please add a space before and after the “>” and “,” in this command.
First, choose your clipped flow accumulation raster, "flowacc_wshed" as raster and 300
as threshold. Then try to generate several stream network layers using different
threshold values e.g. 1000 or 10 000 to get a feeling for the function.
• Specify Output raster : folder and names, e.g. flac_300
• If the Raster Calculator does not work try the Spatial Analyst’s Con function.

Figure 2.3: Usage of the Raster Calculator

Compare the generated Stream Network to other data

The Environmental Agency provides a shape file for channels in Bavaria which we can use to
compare.

• load the layer fgwn_clipped from the folder .\fgwn

6
both the original and ours overlap
each other, and you can see the
similarity

Figure 2.4 Comparison of generated stream network among different sources. (a) the official
vs our delineated river network (threshold: 300 Pixel, flac_300), (b) SWAT delineation and
our step by step delineation (flac_16000)

-------------------
NOTE: For the following section, please just perform the steps in ArcGIS environment. We
will perform the ArcSWAT contents later in the following chapter and will come back here
to compare the results by ArcGIS and ArcSWAT. Do not worry about something confused for
you now, you will get it when we go through the following chapters regarding ArcSWAT.

In the watershed delineation with ArcSWAT we will also obtain a generalized stream network.
This is done to obtain a manageable amount of sub-basins.

To check whether ArcSWAT calls the same functions to delineate the stream network as we
did in ArcGIS environment, we use the same threshold value in now as we will use later with
ArcSWAT. The threshold will be 1000 ha. How many pixels are needed to cover the area of
1000 ha? from where did this value come from

Answer to this question:


The DEM data we used is in the spatial resolution of 25 m * 25 m, that means
1 Pixel cover the area of 25 * 25 = 625 m2
1 ha = 10 000 m2, 1000 ha = 10 000 000 m2
Then the number of pixel will be solved as
10 000 000
= = 16000
625

To facilitate the comparison between stream network generated by ArcGIS and that by
ArcSWAT, here we should prepare a stream network in ArcGIS environment using the
threshold of 16000. The Raster Calculator is used again for this purpose as follows:

7
he didn't do this
• Open Raster Calculator
part, will try it later
• Choose your clipped flow accumulation raster, "flowacc_wshed" as raster and 16000 as
threshold. Type the command Con("raster" > threshold,1)
• Specify Output raster : folder and names,to svae as flac_16000
The output is the Raster type, while in reality the stream network is usually in the format
of Vector/Polyline, we can convert the Raster format to the Vector/Polyline format in
ArcGIS by:
check what • ArcToolbox → Conversion Tools → From Raster → Raster to Polyline
does simplifying Select the flac_16000 as Input raster, name Output polyline as flac_16000shp in the
polygon mean same folder as Raster flac_16000, uncheck the Simplify polylines (optional). Actually
here you can try the output by checking the Simplify polylines (optional) to see the
difference.
To compare our result with the ArcSWAT output, load the layer Reach from
.\ArcSWATProject.mdb
• right click on Layers → Add Data → .\ArcSWATProject.mdb → ArcHydro → Reach
NOTE: the Reach file is in Vector format. You could compare the Reach with our two
stream network files generated in ArcGIS environment, i.e. flac_16000 and flac_16000shp.
Are the three files the same?

Generation of sub-basins
After we generate a general stream network (flac_16000), we can continue to generate a
number of small sub-basins. ArcSWAT actually also divides the whole watershed to a number
of sub-basins. Now we are doing this generation in ArcGIS environment.
this im • Spatial Analyst Tools → Hydrology → Stream Link
done –Input stream raster is flac_16000
with –Input flow direction raster is flowdir_wshed
–Name Output raster as stmlnk
• Spatial Analyst Tools → Hydrology → Watershed
–Input flow direction raster is flowdir_wshed
–Input raster or feature pour point data is stmlnk
–Name Output raster as subbasins (a total of 17 sub-basins, but one sub-basin with
very small size should be merged to nearby subbasin)
Again the output subbasins is the Raster format, we can convert it to the Vector/Polygon format
by:
• ArcToolbox → Conversion Tools → From Raster → Raster to Polygon
–Input raster is subbasins
–Output polygon features as subbasinshp, uncheck the Simplify polylines
(optional).

In the following chapter, ArcSWAT output has a file for subbasins, the name is called as
“watershed”. Then we can try to compare our generated subbasins and subbasinshp with the
ArcSWAT output.
Load the layer Watershed from .\ArcSWATProject.mdb
• right click on Layers → Add Data → .\ArcSWATProject.mdb → ArcHydro →
Watershed

8
Calculation of the statistics (e.g. elevation) for each sub-basin

After generating a number of 17 sub-basins, in many applications we need to know the


differences in the characteristics of different sub-basins? For example, we may wonder what is
the average value of elevation for each sub-basin?
Here is how to extract and analyze the statistics of each sub-basin, in this exercise the Elevation
from DEM is used for example. The Zonal tool in ArcGIS environment will help us to do this
job.

• Spatial Analyst Tools → Zonal → Zonal Statistics as Table. The principle behind this
function is illustrated in Figure 2.5.

• Input raster or feature zone data, the subbasins file are selected. You could use either
Raster format subbasins or Vector format subbasinshp
• Zonal field, automatically be filled. This value will be used as a reference, then you can
link the statistics to the one subbasin that it belongs to. So please remember this field.
Here select ID field.
• Output table, name as subbsnDEMtbl
• Check the Ignore NoData in calculations (optional)
I'll see what • Statiistics type (optional), you can select the type of interest to see, e.g. MEAN
diff it'll make
The Output subbsnDEMtbl will be automatically added in ArcGIS, then Right click this file
and click Open to see the statistics as a table. You can Export this table to a .dbf file and read
it in EXCEL.

Figure 2.5. The illustration of function Zonal Statistics as Table in ArcGIS. Source: ArcGIS
Help 10.1

NOTE: Please try to understand this powerful Zonal tool in ArcGIS environment by reading
the ArcGIS Help 10.1 online document at:
http://resources.arcgis.com/EN/HELP/MAIN/10.1/index.html#//009z000000w8000000
Then you will understand how ArcSWAT calculates various statistics (e.g. Elevation, Slope,
Length, Area, etc.) for each sub-basin and HRU.

9
Linking Table file (subbsnDEMtbl) to Vector file (subbasinshp) for visualization

It is better to visualize the statistics (here is average elevation) to identify the differences among
different sub-basins. The following steps enable you to link the table information to the
corresponding sub-basin.

• Add Data, open subbsnDEMtbl and subbasinshp in ArcGIS


• Right click the subbasinshp, Open Attribute Table to see what fields are included here.
• Right click the subbasinshp, select the Joins and Relates, Join
• Select the corresponding fields as shown in the following figure, then click Ok.
This step uses the same field ID to append the statistics from Table to the Vector
file. Now Open Attribute Table of the subbasinshp to see what happened.

Figure 2.6 Using “Join” function to append table information to a Vector file.
Note that although now you can see that there are more fields in the attribute table
of subbasinshp, all joint fields will disappear if you close the subbasinshp without
saving it as a new file. So if you want to keep the joint fields, please save the
subbasinshp to a new file named as subbasinshp2.

• Right click subbasinshp →Data→ Export data, then name the output as subbasinshp2
save as shape file

10
After joining the statistics, now we are going to visualize the mean elevation for each sub-
basin.
• Right click subbasinshp2→Data→ Symbology
• Setting as shown in the Figure 2.7.
here what For Fields, the MEAN is used as it represents the mean elevation from the
we've done subbsnDEMtbl
is, we've For Color Ramp, you can choose any color you like.
separated For Classification, Click Classify, then a new menu pops up which allow you to
basins change more. Try it yourself.
based on • Click OK, then visualization is done, you can immediately see the difference among
their mean sub-basins and know which ones have lowest value and largest value, as shown in
elevation Figure 2.8.

Figure 2.7 Setting the Symbology of a Vector shapefile

11
Figure 2.8. The visualization of the mean elevation for each sub-basin

Additional Exercise

Create a stream network for another catchment using the original DEM data (dgm). For this
you have to find out how to create a new shapefile and how to edit it to draw a point. Draw this
point somewhere in the entire DEM where you suggest an appropriate gauge would be. If this
is done you can continue with Set a Pour Point.

Find your solution using the knowledge from this exercise, Google, ArcGIS Help online
document, and Youtube video.

IMPORTANT REMARKS
ArcGIS Help online document provides all details for each function or toolbox used here,
please consult this useful document to improve your understanding the principle behind each
function or toolbox.
http://resources.arcgis.com/EN/HELP/

12

You might also like