Professional Documents
Culture Documents
HERBM ExerciseScript Ex1 2
HERBM ExerciseScript Ex1 2
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:
• 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 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.
• ArcGIS: The provided version is ArcGIS 10.6, but the latest version is 10.7. You are free to
choose one from them.
1
• SWAT Check is available at:
http://swat.tamu.edu/software/swat-check/.
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
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
3
Figure 2.1: Scheme of a sink
Compare with the data masked vs. filled, what differences do you notice?
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:
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
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.
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.
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.
The Environmental Agency provides a shape file for channels in Bavaria which we can use to
compare.
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
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
• 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.
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.
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