Difference between revisions of "Slope Analysis using Quantum GIS Processing Toolbox"

From CUOSGwiki
Jump to navigationJump to search
 
(12 intermediate revisions by the same user not shown)
Line 57: Line 57:
 
[[File:Proj.Selection.png|frameless|center]]
 
[[File:Proj.Selection.png|frameless|center]]
   
Once enabled, filter search '''NAD83 (1)''' and select '''NAD83''' under the '''Geographic Coordinate Systems''' '''(2)'''. When finished select '''OK (3)'''.
+
Once enabled, filter search '''NAD83''' and select '''NAD83''' under the '''Geographic Coordinate Systems''' '''(2)'''. When finished select '''OK (3)'''.
   
   
Line 72: Line 72:
 
[[File:Selecting.CSV.png|frameless|center]]
 
[[File:Selecting.CSV.png|frameless|center]]
   
Next you will be asked to choose the projection that the data has. Under '''Geometry Definition''', ensure that you define the proper coordinate system in which the points will be displayed. As before, filter search '''NAD83 (1)''' and select '''NAD83''' under the '''Geometry CRS (2)'''. When finished, select '''OK (3)'''.
+
Next you will be asked to choose the projection that the data has. Under '''Geometry Definition''', ensure that you define the proper coordinate system in which the points will be displayed. As before, filter search '''NAD83''' and select '''NAD83''' under the '''Geometry CRS (2)'''. When finished, select '''OK (3)'''.
   
 
[[File:Geometry.Definition.png|frameless|center]]
 
[[File:Geometry.Definition.png|frameless|center]]
Line 112: Line 112:
 
===Creating a model using Graphical modeler===
 
===Creating a model using Graphical modeler===
   
To create a model workflow navigate to the menu bar, under '''Processing''', select '''Graphical modeler'''.
+
To create a model workflow navigate to the menu bar, under '''Processing''', select '''Model Designer'''.
   
[[File:Image008.png]]
+
[[File:ModelDesigner.png|frameless|center]]
   
Once the modeler window has opened, you can begin to create the desired workflow. For this particular tutorial, the Carp elevation shapefile will be used to create a slope analysis workflow.
+
Once the modeller window has opened, you can begin to create the desired workflow. For this particular tutorial, the Carp elevation shapefile will be used to create a slope analysis workflow.
   
Before creating the model, you must enter a desired model name and group name '''(1)'''. I named my model '''Slope Analysis Turotial''' under a group name called '''GEOM 4008'''. Once a model and group name have been entered, select '''Save (2)''', and save the model to your desired folder. I would recommend creating a folder just for QGIS models under this project.
+
Before creating the model, you must enter a desired model name and group name with the '''Model Properties''' tab, located under the '''Algorythms''' and '''Inputs''' tabs. I named my model '''Slope Analysis Turotial''' under a group name called '''GEOM 4008'''.
   
  +
[[File:Model.Properties.png|frameless|center]]
To begin your model, you'll first have to add an input parameter. On the left side of the modeler window, select '''Vector Layer (3)'''. That will then display a '''Parameter definition (4)''' window. Enter the '''Parameter name''' as '''Input elevation points''' (or something similar), '''Shapefile''' to '''Point''', and '''Required''' to '''Yes'''. Select '''Ok'''.
 
   
  +
Once a model and group name have been entered, select '''Save As''' and save the model to your desired folder. I would recommend creating a folder just for QGIS models under this project.
Now navigate to the '''Algorithm (5)''' tab, to being adding geoprocessing algorithms.
 
   
  +
To begin your model, you'll first have to add an input parameter. On the left side of the modeller window under Inputs, select '''Vector Layer'''.
[[File:InputParameter.png]]
 
  +
  +
[[File:InputtingVectorLayer.png|frameless|center]]
  +
 
That will then display a '''Parameter definition''' window. Enter the '''Description''' as '''Input elevation points''' (or something similar), '''Geometry type''' to '''Point''', and check the '''Mandatory''' box. Select '''Ok'''.
  +
  +
[[File:ParameterDefinition.png|frameless|center]]
  +
 
Now navigate to the '''Algorithm''' tab, to being adding geoprocessing algorithms.
  +
  +
[[File:Algorythm.Tab.png|frameless|center]]
   
 
===Adding Geoprocessing Algorithms===
 
===Adding Geoprocessing Algorithms===
Line 130: Line 140:
 
====3D transformation====
 
====3D transformation====
   
The first algorithm that will be added will transform our 2-dimensional point data into a 3-dimensional dataset. This is required because by default point data in QGIS is interpreted as 2-dimensional meaning that only the X and Y values from the attribute table are considered for analysis, not the Z which is the elevation data. The algorithm used can be found by doing a search filter for '''3D (1)''', and select '''v.to.3d (2)''' under '''GRASS Commands'''.
+
The first algorithm that will be added will transform our 2-dimensional point data into a 3-dimensional dataset. This is required because by default point data in QGIS is interpreted as 2-dimensional meaning that only the X and Y values from the attribute table are considered for analysis, not the Z which is the elevation data. The algorithm used can be found by doing a search filter for '''3D''', and select '''v.to.3d''' under '''GRASS''' and '''Vector'''.
A window will open asking for the specifications '''(3)'''. Enter the specifications that you desire.
+
A window will open asking for the specifications. Enter the specifications that you desire.
 
Make sure that the '''Input layer''' is the elevation point data initially added, and that the Name of attribute column used for height is '''Z'''. Also add an '''Output Vector''' name of your choice. Select '''OK'''.
 
Make sure that the '''Input layer''' is the elevation point data initially added, and that the Name of attribute column used for height is '''Z'''. Also add an '''Output Vector''' name of your choice. Select '''OK'''.
   
[[File:3D.png]]
+
[[File:Vto3d.png|frameless|center]]
   
 
====Inverse Distance Weighted (IDW)====
 
====Inverse Distance Weighted (IDW)====
   
The second algorithm that will be added is an '''Inverse Distance Weighted (IDW)''' [http://en.wikipedia.org/wiki/Interpolation interpolation]. This particular algorithm can be found by doing a search filter for '''IDW (1)''', and select '''v.surf.idw (2)''' under '''GRASS Commands'''.
+
The second algorithm that will be added is an '''Inverse Distance Weighted (IDW)''' [https://pro.arcgis.com/en/pro-app/latest/help/analysis/geostatistical-analyst/how-inverse-distance-weighted-interpolation-works.htm]. This interpolation technique works by assuming that points closer to one another are more similar than those further apart. To predict a value for any unmeasured location, the IDW algorithm uses this assumption as well as the measured values surrounding it (ESRI, n.d.). This particular algorithm can be found by doing a search filter for '''IDW''', and select '''v.surf.idw''' under '''GRASS Commands'''.
  +
  +
[[File:V.surf.idw.png|frameless|center]]
   
A window will open asking for interpolation specifications '''(3)'''. Enter the specifications that you desire.
+
A window will open asking for interpolation specifications. Enter the specifications that you desire.
   
 
Make sure that the '''Input layer''' is the output from the '''2D to 3D transformation'''.
 
Make sure that the '''Input layer''' is the output from the '''2D to 3D transformation'''.
   
For my slope analysis, I had to enter '''Z''' into the '''Attribute table column with values to interpolate''' field because the column under the '''PointDataShapefile''' Attribute Table used for elevation points is named '''Z'''.
+
For my slope analysis, I had to enter '''Z''' into the '''Attribute table column with values to interpolate''' field because the column under the '''PointDataShapefile''' Attribute Table used for elevation points is named '''Z'''. Also add an '''Output raster''' name of your choice.
   
  +
[[File:V.surf.idw.parameters.png|frameless|center]]
I also used a '''GRASS region cellsize''' of '''0.0005'''. This can be changed if you'd like, although it may take longer to process with a smaller cell size value. Also add an '''Output raster''' name of your choice. Select '''OK'''.
 
   
 
I also used a '''GRASS region cellsize''' of '''0.0005''' which can be modified under '''Show advanced parameters'''. This can be changed if you'd like, although it may take longer to process with a smaller cell size value. Select '''OK'''.
[[File:IDW.png]]
 
  +
  +
[[File:V.surf.idw.advanced.png|frameless|center]]
   
 
====Slope====
 
====Slope====
Line 154: Line 168:
 
Following the IDW interpolation, a slope map expressed in degrees will be created using the IDW output.
 
Following the IDW interpolation, a slope map expressed in degrees will be created using the IDW output.
   
Execute a search filter for '''Slope (1)''', and select '''Slope (2)''' under '''GDAL/OGR'''.
+
Execute a search filter for '''Slope''', and select '''Slope''' under '''GDAL/OGR'''.
  +
  +
[[File:Slope.algorythm.png|frameless|center]]
   
This will display a window for the Slope geoalgorithm '''(3)'''. Leave the field parameters as default except for '''Slope expressed as percent''' to '''No'''. Make sure that the '''Input layer''' is the '''Interpolated IDW output'''.
+
This will display a window for the Slope geoalgorithm. Leave the field parameters as default except for '''Slope expressed as percent''' to '''No'''. Make sure that the '''Input layer''' is the '''Interpolated IDW output'''.
   
 
Also add an '''Output raster''' name of your choice. Select '''OK'''.
 
Also add an '''Output raster''' name of your choice. Select '''OK'''.
   
[[File:SlopeAlg.png]]
+
[[File:Slope.algorythm.parameters.png|frameless|center]]
   
 
====Aspect====
 
====Aspect====
   
Execute a search filter for '''Aspect (1)''', and select '''Aspect (2)''' under '''GDAL/OGR'''.
+
Execute a search filter for '''Aspect''', and select '''Aspect''' under '''GDAL/OGR'''.
   
  +
[[File:Aspect.algorithm.png|frameless|center]]
This will display a window for the Aspect geoalgorithm '''(3)'''. Leave the specifications as default. Make sure that the '''Input layer''' is the '''Interpolated IDW output'''.
 
  +
 
This will display a window for the Aspect geoalgorithm. Leave the specifications as default. Make sure that the '''Input layer''' is the '''Interpolated IDW output'''.
   
 
Also add an '''Output raster''' name of your choice. Select '''OK'''.
 
Also add an '''Output raster''' name of your choice. Select '''OK'''.
   
[[File:AspectAlg.png]]
+
[[File:Aspect.parameters2.png|frameless|center]]
   
 
====Hillshade====
 
====Hillshade====
   
Execute a search filter for '''Hillshade (1)''', and select '''Hillshade (2)''' under '''GDAL/OGR'''.
+
Execute a search filter for '''Hillshade''', and select '''Hillshade''' under '''GDAL/OGR'''.
  +
  +
[[File:Hillshade.algorithm.png|frameless|center]]
   
This will display a window for the Hillshade geoalgorithm '''(3)'''. Leave the specifications as default. Make sure that the '''Input layer''' is the '''Interpolated IDW output'''.
+
This will display a window for the Hillshade geoalgorithm. Leave the specifications as default. Make sure that the '''Input layer''' is the '''Interpolated IDW output'''.
   
 
Also add an '''Output raster''' name of your choice. Select '''OK'''.
 
Also add an '''Output raster''' name of your choice. Select '''OK'''.
   
[[File:HillShade.png]]
+
[[File:Hillshade.parameters.png|frameless|center]]
   
 
===Running a model===
 
===Running a model===
Line 186: Line 206:
 
Once all of the geoprocessing algorithms have been added, the model should look similar to the capture below.
 
Once all of the geoprocessing algorithms have been added, the model should look similar to the capture below.
   
  +
[[File:Model.should.looklikedis.png|frameless|center]]
Make sure that you '''Save (1)''' the model before '''Running the model (2)'''.
 
   
  +
Make sure that you save the model to an appropriate place before running it.
[[File:RunModel.png]]
 
   
  +
[[File:Save.model.as.png|frameless|center]]
When the '''Run model''' button is select, a window the same as the capture below will appear.
 
   
  +
Click the '''Run model''' button at the top of the model designer, which appears to the user as a little play button.
In this window make sure you save the output files to an appropriate destination folder. Select '''OK''' to run the model.
 
   
Also check to make sure that '''PointDataShapefile''' is the '''Input elevation points''' that will be Transformed first in the model.
+
When the '''Run model''' button is selected, a window the same as the capture below will appear. In this window, make sure you save the output files to an appropriate destination folder. Select '''Run''' to run the model. In this window, check to make sure that your elevation point shapefile is the '''Input elevation points''' that will be transformed first in the model.
   
  +
[[File:Model.parameters.and.outputs.png|frameless|center]]
[[File:FullModel.PNG]]
 
   
 
Once the model is finished running, the output layers will be displayed in the '''Layer''' toolbox on the left side.
 
Once the model is finished running, the output layers will be displayed in the '''Layer''' toolbox on the left side.
   
[[File:LayerOutput.png]]
+
[[File:Model.output.layers.png|frameless|center]]
   
 
===Displaying output rasters from model===
 
===Displaying output rasters from model===
Line 208: Line 228:
 
One way to change this is to change this '''right click''' on '''Output IDW''', select '''Properties'''.
 
One way to change this is to change this '''right click''' on '''Output IDW''', select '''Properties'''.
   
[[File:IDWProperties.png]]
+
[[File:IDW.properties2.png|frameless|center]]
   
A '''Layer Properties''' window will appear. Navigate to '''Style (1)''', select the '''Render type''' to '''Singleband pseudocolour (2)'''. The rest of the properties can be changed to your personal desire. For my output I selected '''Spectral (3)''' for the color and '''Quantile''' mode '''(4)''' and then selected '''OK (4)'''.
+
A '''Layer Properties''' window will appear. Navigate to '''Symbology''', select the '''Render type''' to '''Singleband pseudocolour'''. The rest of the properties can be changed to your personal desire. For my output I selected '''Spectral''' for the color and '''Quantile mode''' and then selected '''OK'''.
   
[[File:IDWSymbology.png]]
+
[[File:IDW.symbology.2.png|frameless|center]]
   
 
This process can be done for any of the output raster layers. The IDW output was done as an example. The output should look similar to the capture below, depending on the cell size used in the modeling process.
 
This process can be done for any of the output raster layers. The IDW output was done as an example. The output should look similar to the capture below, depending on the cell size used in the modeling process.
   
[[File:IWDOutput.png]]
+
[[File:IDWoutput2.png|frameless|center]]
   
 
It is also possible to change the transparencies of the layers and overlay them on top of one another for more visually pleasing final maps. The following map was created by setting the transparency of the IDW layer to 10% and overlaying it onto of the Hillshade layer.
 
It is also possible to change the transparencies of the layers and overlay them on top of one another for more visually pleasing final maps. The following map was created by setting the transparency of the IDW layer to 10% and overlaying it onto of the Hillshade layer.
   
[[File:IWDAndHillShadeOutput.png]]
+
[[File:Idwplushillshade.png|frameless|center]]
   
 
===Exporting your model===
 
===Exporting your model===
Line 226: Line 246:
 
Once you finish your model it can be exported for further use.
 
Once you finish your model it can be exported for further use.
   
[[File:ModelOutput.png]]
 
   
 
====As an Image====
 
====As an Image====
   
If you'd like to print out the finished model or include it in a report it is possible to save the model as an image for future reference a picture of the model can be saved using the indicated button '''(1)'''.
+
If you'd like to print out the finished model or include it in a report it is possible to save the model as an image for future reference a picture of the model can be saved using the indicated button.
  +
  +
[[File:Export.as.image.png|frameless|center]]
   
 
====As a Python script====
 
====As a Python script====
   
It is also possible to export the model as Python script using the second indicated button '''(2)'''.
+
It is also possible to export the model as Python script using the second indicated button.
This Python script can be edited in a program such as Notepad++.
 
   
[[File:PythonModel.png]]
+
[[File:Export.as.python.png|frameless|center]]
  +
  +
This button will display the model as a python script. From there it can be saved to an appropriate location with the '''Save as''' button. This Python script can be edited in a program such as Notepad++.
  +
  +
[[File:Model.as.python.png|frameless|center]]
   
 
==Raster Calculations==
 
==Raster Calculations==
   
In addition to creating a model using the Processing toolbox, the '''QGIS raster calculator''' can be used to input certain expressions to preform multiple geoprocessing tasks. For the purposes of this tutorial I will be extracting all areas from the slope map that are not flat, (i.e. '''don't have a slope of 0 degrees''').
+
In addition to creating a model using the Processing toolbox, the "QGIS raster calculator" can be used to input certain expressions to perform multiple geoprocessing tasks.
  +
  +
  +
For the purposes of this tutorial, we will start by extracting all areas from the slope map that are not flat (i.e., "don't have a slope of 0 degrees").
 
First navigate to the menu bar, under '''Raster''', select '''Raster Calculator...'''.
 
First navigate to the menu bar, under '''Raster''', select '''Raster Calculator...'''.
   
[[File:CalcSelection.png]]
+
[[File:Raster.calculator2.png|frameless|center]]
   
A '''Raster calculator''' window will open. Inside the expression field insert the following expression '''(1)''': '''( "Output Slope@1" > 0 ) OR ( "Output Slope@1" < 0 )'''. I would recommend manually clicking the operators to avoid typing error. When done entering the expression, at the bottom of the window it should say "expression valid".
+
A '''Raster calculator''' window will open. Inside the raster calculator expression field, insert the expression in the image below. Remember, '''''your expression should reflect the names you have given your output layers'''''. If you have named your raster band differently than I have, please insert the name of your raster band in the place of mine. I would recommend manually clicking the operators to avoid typing errors. When done entering the expression, at the bottom of the window it should say "expression valid".
   
  +
[[File:Raster.calc.expression2.png|frameless|center]]
Remember to save the output as something that is easily recognizable '''(2)''', example, SlopeCalc.tif. Select '''OK (3)'''.
 
   
 
Remember to save the output as something that is easily recognizable, and Select '''OK'''. I named mine "SlopeCalc".
[[File:RasterCalculator.png]]
 
   
When finished you should have an output map like the one indicated below. All areas without a slope of 0 degrees are represented in black and all other areas are in white.
 
   
 
When finished, you should have an output map like the one indicated below. All areas without a slope of 0 degrees are represented in black and all other areas are in white.
[[File:SlopeCalc.png|box]]
 
   
  +
[[File:Slopecalc2.png|frameless|center]]
The following process can be done for any of the output terrain maps. Extracting areas without a slope of 0 degrees was done as an example.
 
  +
  +
Next, we are going to extract all areas from the aspect map with a south-facing slope. To account for southeast and southwest-facing slopes, I created an expression that included all slopes with aspect values ranging from 135 to 225 as "south-facing." Inside the raster calculator expression field, insert the expression in the image below. Again, your expression should reflect the names you have given your output layers. If you have named your raster band differently than I have, please insert the name of your raster band in the place of mine. Again, I recommend manually clicking the operators to avoid typing errors. Remember to save the output as something that is easily recognizable, and Select '''OK'''. I named mine "AspectCalc".
  +
  +
[[File:AspectCalc.png|frameless|center]]
  +
  +
When finished, we are left with a layer where areas without aspect values between 135 and 225 are represented in black, and all other areas are in white.
  +
  +
[[File:Aspect.calc.layer.png|frameless|center]]
  +
  +
Finally, we are going to create a layer which combines the two we just created. This layer will highlight areas that are not flat and are south-facing. In the raster calculator, input the expression in the image below. This combines the attributes of both layers we created in previous steps.
  +
  +
[[File:Slope.and.aspect.png|frameless|center]]
  +
  +
We are then left with a layer that highlights all sloped and south-facing areas of the raster grid in white, with all other areas in black.
  +
  +
[[File:Slopeandaspect.result.png|frameless|center]]
  +
 
The following process can be done for any of the output terrain maps.
   
 
==Conclusion==
 
==Conclusion==
Line 284: Line 328:
   
 
R.E. Crochiere and L.R. Rabiner. (1983). Multirate Digital Signal Processing. Englewood Cliffs, NJ: Prentice–Hall.
 
R.E. Crochiere and L.R. Rabiner. (1983). Multirate Digital Signal Processing. Englewood Cliffs, NJ: Prentice–Hall.
  +
  +
ESRI, (n.d.). ''How inverse distance weighted interpolation works.'' ArcGIS Pro Help. https://pro.arcgis.com/en/pro-app/latest/help/analysis/geostatistical-analyst/how-inverse-distance-weighted-interpolation-works.htm

Latest revision as of 22:59, 4 October 2024

Purpose

The purpose of this tutorial is to guide the Quantum GIS (QGIS) user through the steps necessary to create a slope analysis model workflow using the Processing Toolbox. The user will also learn the basics surrounding the creation of slope, hillshade and aspect maps. The user will also then learn how to export the model as a Python script as well as perform geoprocessing tasks using the QGIS Raster Calculator. This tutorial is designed for a beginner GIS user who has experience with previous GIS software packages however no experience with QGIS.

Introduction

QGIS is a free and open-source geographical information system application that has capabilities in viewing, editing, and geographical analysis. Users can also create and export maps with this software. Within QGIS are tools called "Plug-ins". Plug-ins are essentially developed geoprocessing features made by QGIS developers as well as independent users seeking to expand and contribute to the functionality of the software. One particular plug-in extension found in QGIS is the Processing Toolbox extension. This extension is similar to the features that are found in ArcMap’s ModelBuilder. Processing is an efficient application that is capable of creating, editing, and managing geographical models. The user is able to create workflow diagrams that connect a series of geoprocessing algorithms visually. For the purposes of this tutorial, the user will create a workflow using geographical data of Carp, Ontario in order to create a digital elevation model (DEM). This will then be used to create the slope, hillshade and aspect maps.

This tutorial was completed and revised as a partial requirement of Carleton University's Advanced Topics in Geographic Information Systems 4008 course.

Data

In this tutorial, the only necessary layer is a Comma Separated Value (CSV) point elevation file of your area of interest. We are focusing on Carp, ON. It is recommended that you use the Carp, Ontario data to follow along. It can be acquired and downloaded here. A sample of this data is shown below.

ExampleData.png

In the event that the Dropbox link has become inactive, the process of obtaining this data is described below to keep this tutorial relevant. Access the Government of Canada Geospatial Data Extraction Application here.

In the “Find a location” bar, enter “Carp” and select the following entry from those that appear:

Extent.png

Select the Zoom.png button to center the map on this location.

Next access the bar called “Select clipping area” and select “Current Map Extent”. Under “Select Data to be extracted” Select “Elevation – Point data”. Under “Select options and submit job” fill all of the required boxes so that it matches the figure below. Make sure to enter the email address that you would link to have the file sent to in the “Email Address” field.

DataAccess.png

An email will be sent to the entered email address shortly which contains a URL for the direct download of the data.

If neither of these options are available, since this tutorial starts with a basic csv file it can be run with any other point elevation csv file.

Acquiring QGIS 3.38.3

QGIS version: 3.38.3 (The current long-term release version of QGIS as of September 13th, 2024, is QGIS 3.38.3, and this is the version used for this tutorial. A list of the download links for all of the versions of QGIS can be found here.

Getting Started

Launching QGIS 3.38.3 and starting a Project

When the installation process has finished, an icon should appear on your desktop similar to the one shown below.

QGISFileonDesktop.png

Double-click on the file icon and select the QGIS Desktop 3.38.3 application to open.

QGISDesktopInFile

Select a new empty project from the startup menu.

Once in your project, navigate to the project tab and click "Save as". Ensure that you save your project file somewhere you will be able to find it, and give it an appropriate name.

Saving project in appropriate location

Setting Project Coordinate Reference System (CRS)

Following the launch of QGIS 3.38.3, navigate to the top menu bar, select Project, Properties, then CRS on the left column of the popup window.

Proj.Selection.png
Once enabled, filter search NAD83 and select NAD83 under the Geographic Coordinate Systems (2). When finished select OK (3).


SettingCRS.png

Adding Point Data

Adding the Carp elevation data or your desired .csv data requires navigating to the menu bar, select Layer and Add Layer, Add Delimited Text Layer....

AddDTLayer.png

In the popup window, browse for the .csv file that holds the elevation point data. Select CSV (comma separated values) for the file type. The rest of the options should default to the correct settings, but if the popup does not match the figure below, make sure that you correct these differences.

Selecting.CSV.png

Next you will be asked to choose the projection that the data has. Under Geometry Definition, ensure that you define the proper coordinate system in which the points will be displayed. As before, filter search NAD83 and select NAD83 under the Geometry CRS (2). When finished, select OK (3).

Geometry.Definition.png

There are two possible conversion operations within QGIS for transforming with NAD83. When prompted, choose the option with an accuracy of 2 meters, specific to Canada and offshore Newfoundland.

Conversion.Operation.png

You should now be able to see your point data in the layers panel but your map view will not be focused on this data. Right click on the point data entry in the layers panel and select Zoom to layer.

Zoom2Layer.png

Converting Point Data to a Shapefile

Next we will save this CSV file as a Shapfile to allow for more analysis to be done with it. Right click on the point data entry in the layers panel once again and select Export and then Save Features As.... Choose an appropriate name and file location.

SavePointsAs.png

In the popup that appears, set the format to ESRI Shapefile, set the file name and directory, and ensure that the checkbox beside Add saved file to map is filled. Ensure that the Geometry type is set to Automatic. Select OK once this is done.


SaveVectorLayerAs.png


You should now be ready for analysis!

Processing Toolbox

Open Processing Toolbox

If the Processing Toolbox is not already displayed on the right side of the QGIS 2.18.13 window, select Toolbox under Processing in the menu bar.

ProcessingToolbox.png

This will display the Processing Toolbox on the right side of the screen.

ProcessingToolbosQGIS.png

Creating a model using Graphical modeler

To create a model workflow navigate to the menu bar, under Processing, select Model Designer.

ModelDesigner.png

Once the modeller window has opened, you can begin to create the desired workflow. For this particular tutorial, the Carp elevation shapefile will be used to create a slope analysis workflow.

Before creating the model, you must enter a desired model name and group name with the Model Properties tab, located under the Algorythms and Inputs tabs. I named my model Slope Analysis Turotial under a group name called GEOM 4008.

Model.Properties.png

Once a model and group name have been entered, select Save As and save the model to your desired folder. I would recommend creating a folder just for QGIS models under this project.

To begin your model, you'll first have to add an input parameter. On the left side of the modeller window under Inputs, select Vector Layer.

InputtingVectorLayer.png

That will then display a Parameter definition window. Enter the Description as Input elevation points (or something similar), Geometry type to Point, and check the Mandatory box. Select Ok.

ParameterDefinition.png

Now navigate to the Algorithm tab, to being adding geoprocessing algorithms.

Algorythm.Tab.png

Adding Geoprocessing Algorithms

3D transformation

The first algorithm that will be added will transform our 2-dimensional point data into a 3-dimensional dataset. This is required because by default point data in QGIS is interpreted as 2-dimensional meaning that only the X and Y values from the attribute table are considered for analysis, not the Z which is the elevation data. The algorithm used can be found by doing a search filter for 3D, and select v.to.3d under GRASS and Vector. A window will open asking for the specifications. Enter the specifications that you desire. Make sure that the Input layer is the elevation point data initially added, and that the Name of attribute column used for height is Z. Also add an Output Vector name of your choice. Select OK.

Vto3d.png

Inverse Distance Weighted (IDW)

The second algorithm that will be added is an Inverse Distance Weighted (IDW) [1]. This interpolation technique works by assuming that points closer to one another are more similar than those further apart. To predict a value for any unmeasured location, the IDW algorithm uses this assumption as well as the measured values surrounding it (ESRI, n.d.). This particular algorithm can be found by doing a search filter for IDW, and select v.surf.idw under GRASS Commands.

V.surf.idw.png

A window will open asking for interpolation specifications. Enter the specifications that you desire.

Make sure that the Input layer is the output from the 2D to 3D transformation.

For my slope analysis, I had to enter Z into the Attribute table column with values to interpolate field because the column under the PointDataShapefile Attribute Table used for elevation points is named Z. Also add an Output raster name of your choice.

V.surf.idw.parameters.png

I also used a GRASS region cellsize of 0.0005 which can be modified under Show advanced parameters. This can be changed if you'd like, although it may take longer to process with a smaller cell size value. Select OK.

V.surf.idw.advanced.png

Slope

Following the IDW interpolation, a slope map expressed in degrees will be created using the IDW output.

Execute a search filter for Slope, and select Slope under GDAL/OGR.

Slope.algorythm.png

This will display a window for the Slope geoalgorithm. Leave the field parameters as default except for Slope expressed as percent to No. Make sure that the Input layer is the Interpolated IDW output.

Also add an Output raster name of your choice. Select OK.

Slope.algorythm.parameters.png

Aspect

Execute a search filter for Aspect, and select Aspect under GDAL/OGR.

Aspect.algorithm.png

This will display a window for the Aspect geoalgorithm. Leave the specifications as default. Make sure that the Input layer is the Interpolated IDW output.

Also add an Output raster name of your choice. Select OK.

Aspect.parameters2.png

Hillshade

Execute a search filter for Hillshade, and select Hillshade under GDAL/OGR.

Hillshade.algorithm.png

This will display a window for the Hillshade geoalgorithm. Leave the specifications as default. Make sure that the Input layer is the Interpolated IDW output.

Also add an Output raster name of your choice. Select OK.

Hillshade.parameters.png

Running a model

Once all of the geoprocessing algorithms have been added, the model should look similar to the capture below.

Model.should.looklikedis.png

Make sure that you save the model to an appropriate place before running it.

Save.model.as.png

Click the Run model button at the top of the model designer, which appears to the user as a little play button.

When the Run model button is selected, a window the same as the capture below will appear. In this window, make sure you save the output files to an appropriate destination folder. Select Run to run the model. In this window, check to make sure that your elevation point shapefile is the Input elevation points that will be transformed first in the model.

Model.parameters.and.outputs.png

Once the model is finished running, the output layers will be displayed in the Layer toolbox on the left side.

Model.output.layers.png

Displaying output rasters from model

Once the model is run and the output rasters appear in the Layer toolbox. They will only appear as single band image styles.

One way to change this is to change this right click on Output IDW, select Properties.

IDW.properties2.png

A Layer Properties window will appear. Navigate to Symbology, select the Render type to Singleband pseudocolour. The rest of the properties can be changed to your personal desire. For my output I selected Spectral for the color and Quantile mode and then selected OK.

IDW.symbology.2.png

This process can be done for any of the output raster layers. The IDW output was done as an example. The output should look similar to the capture below, depending on the cell size used in the modeling process.

IDWoutput2.png

It is also possible to change the transparencies of the layers and overlay them on top of one another for more visually pleasing final maps. The following map was created by setting the transparency of the IDW layer to 10% and overlaying it onto of the Hillshade layer.

Idwplushillshade.png

Exporting your model

Once you finish your model it can be exported for further use.


As an Image

If you'd like to print out the finished model or include it in a report it is possible to save the model as an image for future reference a picture of the model can be saved using the indicated button.

Export.as.image.png

As a Python script

It is also possible to export the model as Python script using the second indicated button.

Export.as.python.png

This button will display the model as a python script. From there it can be saved to an appropriate location with the Save as button. This Python script can be edited in a program such as Notepad++.

Model.as.python.png

Raster Calculations

In addition to creating a model using the Processing toolbox, the "QGIS raster calculator" can be used to input certain expressions to perform multiple geoprocessing tasks.


For the purposes of this tutorial, we will start by extracting all areas from the slope map that are not flat (i.e., "don't have a slope of 0 degrees"). First navigate to the menu bar, under Raster, select Raster Calculator....

Raster.calculator2.png

A Raster calculator window will open. Inside the raster calculator expression field, insert the expression in the image below. Remember, your expression should reflect the names you have given your output layers. If you have named your raster band differently than I have, please insert the name of your raster band in the place of mine. I would recommend manually clicking the operators to avoid typing errors. When done entering the expression, at the bottom of the window it should say "expression valid".

Raster.calc.expression2.png

Remember to save the output as something that is easily recognizable, and Select OK. I named mine "SlopeCalc".


When finished, you should have an output map like the one indicated below. All areas without a slope of 0 degrees are represented in black and all other areas are in white.

Slopecalc2.png

Next, we are going to extract all areas from the aspect map with a south-facing slope. To account for southeast and southwest-facing slopes, I created an expression that included all slopes with aspect values ranging from 135 to 225 as "south-facing." Inside the raster calculator expression field, insert the expression in the image below. Again, your expression should reflect the names you have given your output layers. If you have named your raster band differently than I have, please insert the name of your raster band in the place of mine. Again, I recommend manually clicking the operators to avoid typing errors. Remember to save the output as something that is easily recognizable, and Select OK. I named mine "AspectCalc".

AspectCalc.png

When finished, we are left with a layer where areas without aspect values between 135 and 225 are represented in black, and all other areas are in white.

Aspect.calc.layer.png

Finally, we are going to create a layer which combines the two we just created. This layer will highlight areas that are not flat and are south-facing. In the raster calculator, input the expression in the image below. This combines the attributes of both layers we created in previous steps.

Slope.and.aspect.png

We are then left with a layer that highlights all sloped and south-facing areas of the raster grid in white, with all other areas in black.

Slopeandaspect.result.png

The following process can be done for any of the output terrain maps.

Conclusion

In conclusion, this tutorial was aimed to give the user the skills to create workflows using the QGIS Processing Toolbox while also creating a workshop for slope and terrain analysis. This tutorial also gives the user the very basic introduction into the GIS world of Python scripting as well. The Python scripts that were exported can be slightly edited to preform the same geoprocessing tasks but with different parameters if necessary.

Resource Links

QGIS version 2.18 Documentation

GDAL - Geospatial Data Abstraction Library

Aspect - GIS Dictionary

Hillshade - GIS Dictionary

Interpolation - GIS Dictionary

Slope - GIS Dictionary

Python - Learn Python the Hard Way

Notepad++ Homepage

References

Crosetto, M., Tarantola, S., & Saltelli, A. (2000). Sensitivity and uncertainty analysis in spatial modelling based on GIS. Agriculture, Ecosystems and Environment, 81(1), 71-79. doi:10.1016/S0167-8809(00)00169-9

Hutchinson, M.F., 1998. Interpolation of Rainfall Data with Thin Plate Smoothing Splines – Part II: Analysis of Topographic Dependence. Journal of Geographic Information and Decision Analysis, vol.2, no. 2, pp. 152-167, 1998.

R.E. Crochiere and L.R. Rabiner. (1983). Multirate Digital Signal Processing. Englewood Cliffs, NJ: Prentice–Hall.

ESRI, (n.d.). How inverse distance weighted interpolation works. ArcGIS Pro Help. https://pro.arcgis.com/en/pro-app/latest/help/analysis/geostatistical-analyst/how-inverse-distance-weighted-interpolation-works.htm