how to use qgis for hydrology

58
Revised July, 2021 Copyright © 2021, Engenious Systems, Inc. Page 1 How to use QGIS for Hydrology This tutorial looks at the steps and methods required to generate data that StormShed4G can use for analysis. Although the tutorial is specific to QGIS, the GIS methods are common to all GIS programs, hence any GIS program can be used to create the data files that StormShed4G will rely upon. To follow along, download the tutorial data set from: https://www.engenious.com/downloads/QGISTutorialDataSet.zip To the extent possible, we will use the files in the tutorial data set to demonstrate methods and procedures. Copy the contents of the Data set and place in a folder named QGISTutorial. Your folder structure should look like: Project Data folder: In the scenario that we are starting from, much of the preliminary engineering has already progressed to the point where there is sufficient agreement about the project to do some storm water analysis. The work was done on CAD. To get those CAD files to GIS, the relevant layers must be saved as shape files. This folder represents shape files that should be brought to the GIS application. Boundary.shp MHLayer.shp Ex contour.shp Proposed contours.shp Storm pipes.shp Storm struct.shp GIS shape files are not just a single file with the .shp extension. Generally the shape file specification allows for multiple files of the same name but with different extensions. Together the entirety of the group of files are referred to as the shape files. Generally, the shp files created by CAD do not include a .prj file extension. Without the .prj file, the shape file only locates the site and structures using coordinates. The issue is that the coordinates still need to be geo-referenced in order enable the GIS program to locate the site in the correct part of the world. Much of this tutorial attempts to help with that. The ability to geo-reference correctly is a primary source of frustration for novice GIS users.

Upload: others

Post on 26-Nov-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 1

How to use QGIS for Hydrology This tutorial looks at the steps and methods required to generate data that StormShed4G can use for

analysis. Although the tutorial is specific to QGIS, the GIS methods are common to all GIS programs,

hence any GIS program can be used to create the data files that StormShed4G will rely upon. To follow

along, download the tutorial data set from:

https://www.engenious.com/downloads/QGISTutorialDataSet.zip

To the extent possible, we will use the files in the tutorial data set to demonstrate methods and

procedures. Copy the contents of the Data set and place in a folder named QGISTutorial.

Your folder structure should look like:

Project Data folder: In the scenario that we are starting from, much of the preliminary engineering has already progressed to

the point where there is sufficient agreement about the project to do some storm water analysis. The

work was done on CAD. To get those CAD files to GIS, the relevant layers must be saved as shape files.

This folder represents shape files that should be brought to the GIS application.

• Boundary.shp

• MHLayer.shp

• Ex contour.shp

• Proposed contours.shp

• Storm pipes.shp

• Storm struct.shp

GIS shape files are not just a single file with the .shp extension. Generally the shape file specification

allows for multiple files of the same name but with different extensions. Together the entirety of the

group of files are referred to as the shape files.

Generally, the shp files created by CAD do not include a .prj file extension. Without the .prj file, the

shape file only locates the site and structures using coordinates. The issue is that the coordinates still

need to be geo-referenced in order enable the GIS program to locate the site in the correct part of the

world. Much of this tutorial attempts to help with that. The ability to geo-reference correctly is a

primary source of frustration for novice GIS users.

Page 2: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 2

Lidar Files that are tied to quad maps The tutorial example is in Washington State, specifically the Puget sound area. There is a source for

LIDAR available from Puget Sound Consortium

(http://pugetsoundlidar.ess.washington.edu/lidardata/index.html). Generally, users will look through

this site to get a DEM raster and geo-referenced topo images. For this tutorial, we obtained the following:

• 2000-05pugetlow_project.shp

• 2000-05pugetlow_QQ_indes.shp

• 2000-05pugetlow_tile_index.shp

We will use these to figure out what the correct projection is for the CAD files.

SCS Soils Maps These are available from the Natural Resources Conservation Service (NRCS).

http://websoilsurvey.sc.egov.usda.gov/App/HomePage.htm

For this project, we downloaded wss_aoi_2015-08-27_10-39-06.zip, it contains the soils related files

used in this example.

SWMM Although installation of SWMM is not necessary for the QGIS tutorial, you will need it eventually, so

since we are talking about installation here, you might as well install this. It is necessary for backwater

analysis. Install the current version of SWMM, or if you have one of the commercial flavors, then you

can probably skip this installation.

To complete all the steps in this Tutorial Please download the following plugins and install in your version of QGIS. There are python plugins

required to get data from the GIS to make available in StormShed4G.

https://www.engenious.com/downloads/QGISPlugins.zip

This zip file contains three folders. Copy the folders to the

C:\Users\YourFolder\.gis2\python\plugins

Folder. the folder structure will look like:

• C:\Users\YourFolder\.gis2\python\plugins\CNSubAreas

• C:\Users\YourFolder\.gis2\python\plugins\LineSlopes

• C:\Users\YourFolder\.gis2\python\plugins\PipeNetworks

If this is a new install of QGIS, some third-party plugins might need to be installed. Select

Plugins/Manage and Install Plugins from the QGIS menu. Install the following plugins:

Page 3: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 3

• OpenLayers plugin

• Value Too plugin.

Getting Started Create a StormShed4G Project.

• Open 4G, create a project named QGISTutorial. 4G will not permit creation of a project without

an active subscription. (All Subscriptions have a 15-day trial period. The subscription interval

for 4G is 3, 6 or 12 months. Cancelling a subscription before the 15-day trial period effectively

cancels the subscription without any charges.)

o Creating the project in 4G is necessary before attempting to create GIS Layers!

• Save it to the tutorial directory described above. We are saving to d:/junk/QGISTutorial.

• Start QGIS Desktop, Select Project/New to create a new GIS project.

• Load a world view to find your project site. Select Web/QuickMapServices/OSM/OSM

Standard. You could use Google Maps or one of the others as well.

Notice that OSM Standard was added to the Layers Panel.

• Zoom into where the tutorial project is located, perhaps to the County level. Zoom into

Washington state, in the vicinity of Tacoma. It should look like:

Page 4: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 4

• In the Browser panel, navigate to the LIDAR maps that were downloaded

select them, right mouse-click (RMC)and select Add SelectedLayers. The shapes should appear

over your project. In this case they cover most of Western Washington (zoom out if necessary to

get the same view). You will get some dialogs appearing asking for info. Do nothing just click OK

for them.

Page 5: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 5

.

This is a visual indication that the LIDAR maps are correctly geo-referenced in the world.

• In file explorer, navigate to one of the LIDAR shapes, and look at the file with the .prj extension.

In this example, we will open (I use NotePad++, use any text editor that you prefer) 2000-

05pugetlow_projects.prj. It contains the line:

PROJCS["NAD_1983_HARN_StatePlane_Washington_North_FIPS_4601_Feet",GEOGCS["GCS_

North_American_1983_HARN" ,. . .

The bold text is the projection of the map. Select all three shapes in the Layers Panel, right

mouse click (RMC) and select the properties menu item. Select then

click on the to the right of the Assigned Coordinate Reference System section. Change the

Coordinate reference system to the match the bold text.

Hint: in the filter field type nad 1983 harn stateplane Washington <- Notice that this is the

same as above except I substituted a space for the underline (_). Make sure you select the one

that ends in Feet.

Page 6: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 6

Apply the changes to the Properties control and press OK to close it.

• Now change the project coordinate reference system to the same projection (102478) by

clicking on the in the lower right corner of QGIS Window, it opens the Project Properties

dialog. Make sure the Enable ‘on the fly’ CRS transformation checkbox and select the

projection.

Press the OK button to close the dialog, Press Apply and OK to close the Properties window.

Note: So far, we have started the GIS program, displayed a map of the entire world and loaded

LIDAR Index shapes that encompass the location of our project site. Then visually

verified we are looking at the correct part of the world. Then we changed the

coordinate reference system of those LIDAR shape files to what the .prj said they were

(this step isn’t really necessary, but the point is to re-enforce the idea that shape files

are based on a projection. Sometimes you need to tell the GIS what that projection is).

Then we set the project coordinate system to the same projection, and enabled on-the-

fly projection. Once this is done, when you load another shape file, and the shape file

Page 7: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 7

has a .prj file, QGIS can look at the projection that the shape file is based and transform

it to the project coordinate system automatically. Works most of the time, somethings

not.

• In the Browser Panel (if not visible, it can be found View/panels/BrowserPanel) select all the

CAD Shp files in the ProjectData folder. Right mouse click (RMC)and select boundary, MHLayer

and storm pipes files with the .shp extension. Depending on the state of the project, QGIS will

either provide warnings about the CRS or present a dialog asking for the projection of each

layer. Just in case, sequentially select each layer in the Layers Panel by RMC on it and select Set

Layer CRS menu option. Select EPSG:102478.

Since these are CAD files, they didn’t have a .prj file associated with them, so we need to

explicitly tell QGIS the CRS to use on them. We selected EPSG:102478 because that is the LIDAR

projection.

• Look at where the project CAD files are relative to the Puget sound Index layers, they should be

in the right location, which is in Pierce County Washington, but they aren’t. To fix this RMC click

on the layers again and choose:

• and manually adjust their projection to EPSG:102479 by selecting

To set the projection.

Note: We find it strange and cannot explain why just about everything lines up based on NAD

StatePlane Washington North except for engineering drawings in Washington. More

times than not, we have found that they don’t map correctly unless we tell the GIS

program that their projection is NAD StatePlane Washington_South. Incidentally, since

Page 8: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 8

this project is old, the OSM map now show the completed project, when we initially did

this tutorial, the site was empty.

• Let’s insert the soils data. Navigate to the spatial directory of the SCSSoils folder and open

soilmu_a_aoi.shp by RMC on it and Selecting Add Layer. They can all be opened, but generally,

the largest shp file normally contains everything that is needed. It should open directly over

your project. The soils should have a WGS 84 world projection (look at file with same name but

with the .prj extension), since we set the default CRS projection (See lower right of the QGIS

desktop) to EPSG:102478, it should be georeferenced correctly. Move the layer below the

boundary layer to see it.

Page 9: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 9

To get those colors, open the properties dialog for the soilmu_a_aoi layer and modify the styles.

This is roughly what I did.

• If you don’t want to take the time to figure out how to style it, RMC of the soilmu_a_aoi layer

and select Properties, then at the bottom left select the Style dropdown/Load Style and select

the SCSSoilStyle.qml file the SCSSoils project folder.

• Turn all layers off except for the boundary layer. Then turn on the 2000-05pugetlow_tile_index

layer. Zoom out to see the quadrangle map outlines. Use the Properties dialog to add the Label

to it. In this case the label is based on the QQuadTile column.

Page 10: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 10

This shows us that the project site is located in q47122b3207. (Load the TileIndex.qml style)

• From the LIDAR site referenced at the beginning of the tutorial, add the .tif file associated with

that location as a new layer. (it is also included with the tutorial data set, in the LIDAR folder).

Digital imagery is available from many locations, in Washington State try

http://guides.lib.uw.edu/c.php?g=341497&p=2299097 or from the USGS

http://viewer.nationalmap.gov/launch/

• Go to the Browser Panel and RMC on q47122b32be.tif and Select Add Layer, it’s projection is

EPSG:102478. Set it by RMC on properties and setting its CRS (coordinate reference system).

Look at it and move it below the site CAD layers so that the layers are above the tif.

Note: The reason why it is necessary to manually set the crs for the tif file is because tif’s have

no projection, hence even though the project as a default projection of 102478 and CRS

on the fly transformation is selected, the project doesn’t know how to transform the tif

file.

• We will use this layer later. It should appear either over or under the boundary layer. Move it

below the boundary layer to view appropriately. Hide the layer for now.

Comment: The first part of putting together the project is done, everything lines up correctly.

Unfortunately, there is more work to do to make it useful. It would be a good idea to save the project

now. Save it to the QGISTutorial folder. Save it as QGISTutorial.

Making useful maps The previous section just got all the necessary info lined up, . . . properly geo-referenced. Now we need

to create layers that are useful.

Get the Site Area I’m sure the first thought is that we have the boundary layer from CAD. That works.

Page 11: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 11

• Click on the boundary layer to make it active.

• Click on the Attribute table button in the toolbar, or right mouse click (RMC) on boundary and

select Open Attribute Table.

There’s no area, just angles and lengths. The problem is the CAD shp file is a line file, not a

polygon file. The first thing that needs to be done is to create a new shp layer and make it a

polygon layer. Close the Attribute table. The steps are:

• Select Layer/Create Layer/New Shapefile Layer,

• Specify the type as Polygon,

• Set the Coordinate Reference System (CRS) as EPSG:102478, and

• In this version of QGIS, it is necessary to navigate to the QGISTutorial folder location

and enter the name PolygonSiteBoundary to create the layer.

• Select Views/Toobars/Snapping Toolbar to make sure the tools are displayed on the

screen. Once you have verified that the Snapping toolbar is there selected the below

options:

You are enabling snapping, on vertex, at intersections.

Page 12: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 12

• With the PolygonSiteBoundary active, click on the button to enable editing.

• Click on the to begin adding features.

• Starting at the upper left corner, moving clockwise, snap to each snap point until

finally snapping on the lower left corner. To close the polygon, RMC and enter an id

in the popup window. Enter 1, press OK.

• Finally, click on the again to conclude the editing session. Save the polygon

layer when asked.

• RMC on it and set the CRS to 102748.

Note: Use the Snap to Point feature and snap to all points in the boundary layer. There is a

QGIS feature Vector/Geometry Tools/Lines to Polygons. . . that might work, depends

on how exact the end points of the lines match up. For this project the autocad lines

apparently didn’t line up correctly.

Open the attribute table for the new PolygonSiteBoundary Layer. If the area isn’t displayed,

add it by clicking on the field editor button, , Creating a new field, then selecting $area

under Geometry in the middle column, divide it by 4047. Make the field name Area, change the

field type to Decimal number and change the precision to something relevant, for example 6.

Press OK. We like to change the fill for the layer to Transparent, and leave the border

something that’s easy to see, like Red.

about 6 acres. At this point the boundary layer can be

removed from the QGIS project. Note: Your area will differ depending on how you snapped

Page 13: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 13

around the boundary. Selecting $area will give area in square meters divide by 4047 to get

acres.

Getting areas for sub-basins This is more complicated than one would like. To get drainage areas, we need to know how runoff flows

through the site. We already know where the site is, so all we need to do is super impose a DTM or

DEM over the site. In most cases, engineers have a survey of the site, maybe a little bit outside the site

boundary, probably not the entire watershed. This is where LIDAR comes in.

Looking at Elevations We are now at the point where elevations matter. Elevations/slopes are the basis for the establishment

of drainage areas. The CAD files probably include layers for existing and proposed contours. The simple

solution is to create DEM/DTM models from that. If they are available, then there isn’t a need for LIDAR.

If not, LIDAR data will have to do. This section illustrates how one would use LIDAR generated data.

• Turn off all layers except the PolygonSiteBoundary layer. We no longer need the CAD boundary

shape file (it can be unloaded if you wish).

• Turn on the layer q47122b32be, this was added earlier and hidden, to make it visible.

• Position it below the PolygonSiteBoundary Layer. It is much larger than necessary. Using it at

that size will be very time consuming. What is the correct working area for a DEM raster? The

answer is whatever is needed. There are very few sites that sit at the apex of a mountain where

everything drains away from the site, and nothing drains into it.

Assuming yours is located within a watershed and not at the apex, the working DEM Raster

needs to be large enough to include all areas draining into the site. It also needs to include area

downstream of the site for whatever regulatory condition that is required.

This section will just use the entire quadrant (rather than crop it to a small size to increase speed

and decrease processing time). The assumption is that the entire project is enclosed in this

quadrant (otherwise it will be necessary to merge a couple quadrants together – QGIS has basic

tutorials on how to do this). We will focus on how to manipulate QGIS to arrive at a reasonable

existing drainage area.

Note: We like to know what the elevation is at the mouse location. QGIS has a plugin named Value

Tool that does provides this information.

Using QGIS Hydrology features. The previous version of this tutorial used the TauDem ( https://hydrology.usu.edu/taudem/taudem5 )

library. In this tutorial we well switch to libraries that are more open source and better supported.

Please refer to the

Page 14: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 14

• Stream and catchment delineation in QGIS 3: https://www.youtube.com/watch?v=Ro-

RRzMMw-c. It is an excerpt from the “QGIS for Hydrological Applications” book by Hans van der

Kwast and Kurt Menke.

Steps to figure out existing drainage paths: • Make the q47122b32be layer visible.

• Fix any problems that there might be with the quad layer by filling the sinks. This is done using

the Processing Toolboxs. Make it visible by selecting Processing/Toolbox from the application

menus.

• There are a lot of tools present, we will focus on the SAGA/Terrain Analysis tools (Channels and

Hydrology).

• Search for Fill sinks and select:

Fill out the Dialog as follows:

Page 15: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 15

Notice that we unchecked a couple of check boxes, also notice that no filenames are entered.

QGIS3 allows creation of temporary files, which is what we want in this case. (We will

eventually end up with a file that we do want to save.)

• Select Run and let it process. Once it is finished, we can style it which is not something I

would generally talk about in a tutorial, but this is a flat site. If you select

Properties/Symbology for the Filled DEM layer, you can start styling the elevations.

• Note that the min is 1 and the Max is 254. That is because we are using the entire quad

map. If you look at the elevations for the site. It’s pretty flat. (Use the Value tool and move

your mouse around the site and look at the elevations).

o To make the colors reflect the range within the project boundary. Set the min to

170 and max to 200. (The 170-200 is somewhat arbitrary, got it by moving the

mouse around the boundary area to see what the min-max elevations might be)

o For color ramp, select the drop down and choose Create New Color Ramp.

o Change Gradient to Catalog: cpt-city

o Click OK then choose Topography/elevation.

Page 16: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 16

• You should end up with something like this:

• And the site should look something like this:

Page 17: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 17

After creating a FillDEM layer, progress to the Strahler order. What is that? You will get it once we

see what it does.

• Select SAGA/Terrain Analysis – Channels/Strahler order.

• In this case we are going to save it to a file that we intend to keep.

• Then Run it.

• When it is done, you will get what it does. Strahler order defines the streams paths as a

progression from 1 to 10, where 1 is the smallest stream and 10 is the largest stream.

• This is a flat site, there aren’t any streams. Strahler shows you where the water is going.

• We can clarify what we see using symbology. RMC on the Strahler layer/ select properties

and Symbology again.

• Set the symbology as SingleBand Pseudocolor/ Linear interpolation / the Blue color ramp is

OK.

• Make the Mode equal interval with Equal Interval, the select the Classify button.

Page 18: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 18

• When we click Apply, and OK, turn off all layers except the Strahler layer and

PolygonSiteBoudary. It should look something like:

• Theres a lot of noise. Lets do something about it.

• Select Raster/Raster Calculator

o Select Strahler@1 (double click on it) from the Raster Bands.

o Define a output layer, I will call it Strahler5 in this example

Page 19: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 19

o And change the expression to “Strahler@1” >= 5 – it looks like this

o The layout now looks like (change the polygonSiteBoundary layer to have a red line)

o o Repeat the above and try “Strahler@1” >= 3.

Page 20: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 20

o o Strahler3 gives enough definition to draw polygons around drainage areas.

Comment: This site is flat, so delineating basins by hand is often preferrable. The QGIS

toolbox has tools in SAGA/Terrain Analysis – Channels/Channel network and drainage

basins that will delineate the drainage basin for you. They are talking about hydrologic

drainage basins. Not runoff from a 6 acre site.

o The next step is to draw polygons around the drainage areas that matter. We did

this before when creating the boundary, except this time we aren’t snapping to

AutoCAD lines. Instead, we are drawing outlines around the “streams”. I ended up

with four polygons on a layer named DrainageAreas. (Load DrainageAreaStyle.qml)

o For this tutorial the drainage areas will look something like this (after styling it –

random color ramp and about 50% opacity. Label is based on Id and blue color,

about 20 pixels)

Page 21: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 21

o );

o Not bad, but drainage areas 2 and 4 represent on site and off site areas. To figure

out what the off site component is, select Vector/GeoprocessingTools/Union.

o Enter the Boundary layer and the DrainageAreas layers. We want to save this layer,

so name it OnAndOffSiteAreas.

o

Page 22: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 22

o Run it and you will end up with:

o o Looking at the Attribute table (F6), we see that there are three columns (id, Id_2,

Area). First, delete the area . Select Area, the delete it.

o Add a new Column by creating a new virtual field, call it Area

Page 23: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 23

Note that selecting a row by clicking on the row number, will highlight the shape on the

canvas. Selecting Row 4 will look like - (Pretend that the Recid column do not appear in

the images, that column will be added below).

Page 24: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 24

Some of the rows are areas created by points not snapping to other points, creating

areas where there should be a shared boundary. In this case, I’m going to get rid of

rows 1, 2 and 8. 1 and 8 is bad snapping. 2 is the boundary outline, we don’t need that

here.

o Add a new field by clicking on . Add

o When the table has added the column edit each row as follows:

Page 25: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 25

o

Now we have accurate on and offsite drainage areas.

Let’s style the OnAndOffSiteAreas layer so it looks like this (also set the opacity to 50%):

Page 26: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 26

You can simply copy the PolygonSiteBoundary style to the OnAndOffSiteAreas layer. RMC on

PolygonSiteBoundary, select Styles/CopyStyles, then RMS of OnAndOffSiteAreas layer, select

Styles/PasteStyles.

Get the HSG values for the site Note: There are issues with relying on CN numbers. See the following references.

• https://www1.villanova.edu/content/dam/villanova/engineering/vcase/sym-

presentations/2001/B32.pdf

• https://acwi.gov/sos/pubs/2ndJFIC/Contents/10E_Hawkins.pdf

It doesn’t change the fact that reviewing agencies requiring SCS methodology will still require CN

numbers. This section shows one method of obtaining the HSG for the site soils. We don’t know if it is

better or worse than relying on the Soils report to provide the soils type based on one or two site

samples. Using GIS, we can at least get areas that are associated with the different soil types

throughout the site. You can get the data from the USDA site

(https://www.nrcs.usda.gov/wps/portal/nrcs/soilsurvey/soils/survey/state/). The map is found at:

https://websoilsurvey.nrcs.usda.gov/app/WebSoilSurvey.aspx

Turn on the soilmu_a_aoi layer, it will look like this:

Page 27: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 27

The purpose of this section is to further divide the areas for each basin into the associated soil types.

Use the Vector/GeoprocessingTools/Intersection menu item. This time use the OnAndOffSiteAreas

layer with the soilmu_a_aoi layer. Save it new layer to a real file named

OnAndOffsiteAreasWithSoils.shp

Page 28: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 28

Notice:

That is where we get rid of the layers we don’t need.

There are a lot of columns in the soilmu_a_aoi layer so let’s edit fields in both tables. For the

OnAndOffSiteAreas table we can get rid of the Id, Id_2 and Area columns (check the Recid column). For

the Soil layer, we can get rid of the AreaSymbol, SpatialVer and MUSYM columns.

Once it has run, turn off the soilmu_a_aoi layer and the OnAndOffSiteAreas layer. Style the layer and

you will see something like:

Page 29: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 29

The result is a layer with only the following attribute columns. Recid, MUSYM, MUKEY. This isn’t

enough. The MUSYM and MUKEY columns link the soilname and HSG to the Recid. They can be found

in the folder: SCSSoil/tabular/component.txt file.

What 4G ultimately wants are columns Area (in acres), SoilName, HSG, a unique Id for 4G and a unique

Id for the table.

We will manually add the columns via the familiar button for the layer. The requirements are:

Area:

Page 30: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 30

Soil name:

The values 74665, 74670 and 74673 and McKenna, Norma, Kitsap come from inspection of the

components.txt file

HSG:

Page 31: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 31

The relationships between mukey and HSG also come from the components.txt file.

Unique Id for 4G:

The uuid is found under Records and Attributes. 4G wants the ‘Id128’ format.

Id for the table row:

Page 32: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 32

This is just the row_number. We want this to make sure we always get a unique row.

The table should look like this:

Page 33: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 33

Area-CN Wrap-up Having the OnAndOffSiteAreasWithSoils shp file is nice, but it really isn’t in the StormShed4G database

where it is useful. We need to import it into the StormShed4G Project. Select Database/DB Manager,

select the StormShed4G project file . Select and

select Replace destination table (if exists). At the time of writing this tutorial, selecting the drop down

and picking OnAnOffSiteAreasWithSoils failed to import the table. You need to select the button

and pick the .shp layer from the file picker.

Page 34: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 34

This creates a Table in the StormShed4G Project named GISPCN. It will be used to create the PCN values

associated with each StormShed4G Basin. If you had gone through the above steps with impervious

areas, they would go to the GISICN table instead.

Hint: Rather than redo the style from the Layer OnAndOffSiteAreas into this new layer,

OnAndOffSiteAreasWithSoils, you can simple copy the style.

• RMC on the OnAndOffSiteAreas layer, Select Styles/Copy Style/All Style Categories.

• RMC on the OnAndOffSiteAreasWithSoils layer, select Styles/Paste Style/All Style Categories.

Time of Concentration Getting the time of concentration for a watershed basin can be tricky. There are lots of different ways

to compute time of concentration. Time of concentration is defined as the longest time it takes for

runoff to accumulate at a downstream point of analysis. Conceptually, it is the time in which runoff

Page 35: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 35

from all points in the upstream basin contributes flow at the point of concentration. The method that

the SCS or TR-55 uses is to divide the runoff path to the point of analysis into sheet, shallow and channel

drainage paths, requiring the lengths and slopes of the runoff segments need to be known.

This section demonstrates how QGIS can be used to derive those segments. Start with these layers

turned on:

It should look like this:

We will be working with basin B-002. This is a flat site and trying to figure out the longest travel time is

not so easy. Here we are using the Strahler3 layer to show us how the flow travels. We can simply

measure the longest path. If you move your mouse around (with the Value Tool plugin installed) you

will see that the elevations jump around a lot. To help visualize what is happening, we can create a

contour map so that we can see where the valleys are.

Clip the q47122b32be layer so that we do not contour the entire quad map. Select

Raster/Extraction/Clip Raster by Extent

Page 36: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 36

For input layer, use the q47122b32be layer. For the clipping extent, use the DrainageAreas layer. Set

Assign a specified nodata value to output bands as –999

After running, a new layer called clipped(extent) is created. Turn off the q47122b32be layer. It is based

on meters. To convert it to feet, use Select Raster/RasterCalculator and create the layer

Clipped(extent)InFt by:

Page 37: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 37

Select Raster/Extraction/Contour

For interval we tried an interval of 2 first, but that was too busy, so we tried an interval of 4 next.

Create a Temporary Scratch Layer:

Page 38: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 38

Turn on the DrainageAreas, 4 ft Contour map, Strahler 3 layer and Clipped layer. Locate low points

along the path to the property line or the point of analysis for the drainage area 2. So, starting with this:

And ending up with this:

Page 39: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 39

The points are visually located along the drainage course as defined by the contours.

Page 40: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 40

Add an Id to each dot. Click for the New Scratch layer and add an Id

Pick up the elevations at each dot. In the Processing Toolbox, search on Sample, the select Raster

analysis/Sample raster values.

Create another scratch layer:

Page 41: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 41

Create a polyline layer connecting the dots.

Select Layer/Create Layer/New Temporary Scratch Layer. Navigate to your StormShed Project and

name it PerviousTTLayer, make it a LineString and set the CRS. Define an Recid that is a Text type with

a 40 character length.

Page 42: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 42

Connect the dots. And save it as line 1. Enter the id as

Looking at the attribute table, there is only one item. Not very helpful. What we really want are the

individual lines that make up that run. In the Processing Toolbox search for explode. Also turn off

contours layer.

Save it to another temporary scratch layer.

The attribute table is a little better:

Page 43: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 43

but still not very helpful. Add the length to the attribute table by clicking on

and entering

Take a look at what we have now (You will need to adjust the styles of the Sampled and Exploded layers

to get this view:

Page 44: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 44

To get slopes of the lines, we can use the drape command. Create a new layer named

DrapedPerviousTTLayer by searching for drape in the processing toolbox.

Then filling out the instructions:

Page 45: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 45

Then adding a Slope field to the Draped layer:

The Draped attribute table now included a Slope column – note that the slope is compute in ft/ft. The

attribute table now looks like:

Page 46: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 46

Clearly from a Time of Concentration perspective, the elevations are all over the place, and hence the

slopes are all over the place. If this were a real drainage basin the elevations would probably make

more sense, for a flat site, this is probably what you will get. Realistically, along the drainage path,

there are a lot of sinks that need to be filled before overflowing to the next downstream sink. Looking

at the contours, if I were manually doing this, I would start at elevation 610 ft, go 28 ft to elevation 584,

then I would pull the entire remaining distance to last point. Looking at the contour map is 584. But

Elevation 584 to elevation 584 doesn’t work, so I’ll make the elevations from 610 ft to 584.5 ft to 584 ft

for the travel time distance and slopes. The slope for the drop from 0.5 ft over 155 ft is about 0.0032 or

0.32%.

If I zoom in on the contours it looks like:

at the upper end and

Page 47: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 47

at the lower end. So going from 584.5 to 584 is just a judgement call. The whole exercise for a flat

project is academic, but it provides a sense of what the TT really is. We now know the 6 inch drop over

the sum of the length will give a TT that does not account for the sinks. We also know that there are a

lot of sinks, hence a when we model in StormShed4G, there will be a lot more time for the ground to

soak up water than the TT would suggest.

Anyway, in StormShed4G we can adjust the parameters accordingly. But for now, we are going to

pretend that everything is fine and transfer the data to StormShed4G.

We still need to identify the drainage area associated with these segments.

Now that each row is associated with a StormShed familiar basin name, the Id column must be added as

follows:

We can add another column that is required for spatiaLite:

Page 48: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 48

The result is an attribute table that looks like:

Export the Draped layer to the StormShed4G project db by selecting Database/DB

Manager/SpatiaLite/TestApi.sqlite then selecting the button.

Page 49: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 49

If the above failed with “loading of Draped failed”, it is because you need to save the editing of the

Draped Layer unclicking the button, or you selected the layer from the drop down instead of

selecting the DrapedPerviousTTLayer.shp file from the button.

Page 50: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 50

Appendix

How to get Elevations at Nodes From

DEM This is straightforward. It is used to get elevations from lines.

• Create a new project.

• Add the raster layer q47122b32be to it.

o Make sure to set the CRS to EPS 102478 as well as the default projection.

• Create a new shapefile layer based on polylines and enter a couple of polylines. It will look like

this:

• Select Vector/Geometry Tools/Extract Nodes to get nodes in polylines.

o For Input line or polygon vector layer, select the name of your polyline shape file.

o For output point shapefile, give it something, like NodesInPolyline.

• Open the attribute table for the NodesInPolyline shapefile, and give each Node a unique Id (N-

001, etc);

o Add a column for the nodeid’s and leave the polyline id’s this allows us to identify pipe

runs.

Page 51: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 51

o • Use Point Sampling Tool Plugin to get elevations at each Node:

o When using this tool select all fields that you want to be moved to the new shape file.

o For the output vector layer, give it a name like NodeElevations. When it is created look

at the attribute table, it will contain three columns id, NodeId, and q47122b32b. The Id

column has a identifier that identified the original polyline. q47122b32b is the elevation

at each node.

• Use Processing/QGIS geoalgorithms/Vector geometry tools/Explode lines tool to break

polyline into lines. What you will end up with is not impressive, looking at the attribute table:

Page 52: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 52

o Add three columns to the attribute table, Length, yCoord, yCoord, all decimals widths of

20 and precision of 10.

o For length just select under Geometry, $length

o For xCoord select under Geometry, $xat and enter $xat(0) for the expression.

o For yCoord select under Geometry, $yat and enter $yat(0) for the expression.

o The Attribute Table now looks like:

• Now we need to add some columns to the NodeElevations Attribute Table.

o Add the same two columns for the NodeElevations Table as the previous. Add

upXCoord and upYCoord. It now looks like:

Page 53: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 53

• Finally, we are going to do a join on the ExplodedPolyline layer. Click on the layer to select it.

Then select the menu Vector/Data Management Tools/Join Attributed by Location.

o The Target Vector layer is the ExplodedPolyline layer.

o Join vector layer is the NodeElevations layer

o For Attribute Summary, select the Take attributes of the first located feature, this would

be the upstream node location assuming the polyline was drawn upstream to

downstream.

o Give the output shape file a name like CompleteExplodedPolylines

o Probably keep all records.

o When completed, open the attribute table for CompleteExplodedPolylines and add a

column for the length.

o Next add a new column named ReachId, manually enter a unique reach id for each row.

It should look something like this:

Page 54: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 54

Computing Areas We aren’t in the business of teaching GIS, however, since most of our user are probably going to be US

based and will not be using the metric scale, be careful about units. In the above example, we are using

the following projection:

EPSG 102478. The name is NAD_1983_StatePlane_Washington_North_fips_4601_Feet

There are two ways of computing the area of a shape file, for example PolygonSiteBoundary as created

in the tutorial. The first and easiest way is to open the layers attribute table by clicking , then

adding a field by clicking followed by then filling out the table:

You will then see a new column added to the attribute table:

Page 55: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 55

The problem is that the area you see is in square meters, not the expected square feet value (we know

the site is about 6.2 ac).

To get it right, we find that we need to do the math:

To get the expected answer:

We hope that someone will be able to explain this and possibly correct what we have shown above.

The second method The second method is to use Vector/Geometry Tools/ExportAddGeometry Columns:

Page 56: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 56

To give you area in sq ft.

This involves creating yet another layer.

Page 57: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 57

Appendix

GIS Table Formats The integration with StormShed4G relies on the ability of transfer data from a GIS Layer to 4G. There

are basically three types of data that 4G requires. They are data related to Basins, Nodes and Reaches.

Basins 4G basins support SCS/SBUH and Rational basins. Data that is obtainable from GIS that can be used by

each 4G basin is the drainage area and travel time lengths. In support of the variations of area and

travel time lengths, 4G will accept two types of layers and attributes.

Basin Subareas The first type of GIS layer is a (curve number) CN type layer. Each basin is made up of multiple CN areas.

As a minimum, the attribute file must contain the following attribute columns:

• Id – This is a unique uuid. It is created by using the expression uuid(‘Id128’).

• Id2 – This is also a unique value, but it is an integer. It is created using the expression

@row_number.

• Recid – This is another unique Id, referencing the familiar name of the basin. Those familiar

with Stormshed will recognize it as a default Basin id such as B-001.

• Mukey – This is the soil identifier key. See tutorial.

• Area – Area of the subarea in acres.

• Name – Soil name.

• HSG– hydrologic soils group. It will be A, B, C, D or some combination C/D

There are potentially two tables using the above format. One for Pervious CN subareas, and the other

for Impervious CN subareas.

Tablenames must begin with GIS. In the tutorial the GISPCN table was created. An actual project would

also have a GISICN table. Names such as GIS_Pervious and GIS_Impervious would also be acceptable.

Do yourself a favor and omit spaces in table names.

For Rational basins, create a table with the above format, use the GIS_xxx naming convention. When

importing to 4G, it is considered an Impervious type CN Layer.

Travel Time tables The second type of GIS layer is the Travel Time (TT) type layer. Each basin is made up of multiple travel

time segments of varying length and slope that is used to estimate a travel time to the point of analysis.

As a minimum, the attribute file must contain the following attribute columns:

• Id – This is a unique uuid. It is created by using the expression uuid(‘Id128’).

• Id2 - This is also a unique value, but it is an integer. It is created using the expression

@row_number.

Page 58: How to use QGIS for Hydrology

Revised July, 2021

Copyright © 2021, Engenious Systems, Inc. Page 58

• Length – in feet of the segment.

• Slope in ft/ft of the segment.

• Recid – Is a unique Id referencing the id of the familiar name of the basin, for example B-001.

Tablenames must begin with GIS. In the tutorial the GISPTC table was created. An actual project would

also have a GISITC table. Names such as GIS_PerviousTT and GIS_ImperviousTT would also be

acceptable. Do yourself a favor and omit spaces in table names.

Nodes 4G Nodes are transition points. They are manholes, detention ponds, vaults or other storage structures.

In GIS these types of entities can be located as points at a certain location. 4G will expect a GIS table

with the following columns:

• NodeId – the familiar name for the node, N-001

• North – coordinate

• East – coordinate

Reaches In 4G a reach is a pipe or a ditch or anything that conveys runoff from an upstream node to a

downstream node. 4G expects a Node table (above) to be accompanied by a Reach table where the

reaches connect the nodes. The reach table must have as a minimum, the following attribute columns:

• FromNode – the node at the upper end of the reach.

• ToNode -The node at the lower end of the reach.

• RchId – The familiar name of the reach, for example, R-001