Terrain Analysis with GRASS tools in QGIS

From CUOSGwiki
Jump to navigationJump to search

1 Introduction

This Wiki page was created for Advanced Topics in Geographic Information Systems (GEOM 4008) students at Carleton University. The main purpose of this tutorial is to introduce and familiarize future users to understand the Raster Terrain analysis within Geographic Analysis and Support Systems (GRASS) tools in QGIS. Many familiar topics will be touched upon, know that a basic understanding of geomatics or similar fields of study are needed as the complexity and the terminology are subjective based on geomatics and data processing techniques.

2 Objective

The purpose of this tutorial is to touch on the concept of terrain-based analysis using raster data. It will also include a plan with detailed information into each step as to why the identified steps and processes are important. Other general concepts and functionalities are also to be found with quick tips and tricks. Due to the specificity of GRASS tools and the QGIS workspace many steps will have to be repeated to ensure proper procedures and develop the appropriate data. The Area of Interest (AOI) for this tutorial is Gatineau Park, and the analysis details in the steps create an elevation and depression model based on various resolutions. One can find supporting literature and videos linked in the Reference section.

3 Data

The type of raster data that we will be using is referred to as DEM or Digital Elevation Model. It contains information that is specific to determining things like Aspect and Slope. Slope and Aspect are important as they refer to the degree, length, and direction of the pitch. The combination of these two data inputs will create the model by which we can analyze various depressions and flow pathways in the AOI or Gatineau Park.

4 Methods and Data Setup

4.1 QGIS Setup

Before beginning the tutorial, you must install QGIS version 3.22.2; first, download QGIS to your computer.

Please follow the steps below:

Click this link to download QGIS to your personal computer.

• Choose which version is compatible with the computer you are working on. For me, this is version 3.22.2. Follow the steps in the pop-up downloading window. But note, the latest version is preferred for this tutorial.

• There are many sources that can provide QGIS workspace software packages. For this tutorial, the link and the steps below are specific to this source and the available versions of QGIS.

4.2 Opening QGIS

• Once you have completed the installation of QGIS and found all the data you want to use, create a folder on your computer and place the data in your created folder.

• Click the QGIS icon to open the program. This will open the QGIS application. QGIS Application.jpg

• After QGIS opens up, add the Raster data to QGIS space as detailed below...

4.3 Adding Raster Layers to QGIS

• Find the layer option in the header, click ‘add layer’ and then click’ add raster layer’. Add the Raster layer to the data set.

Raster Option.jpg

• Once your data has been added, right click on the data, select properties, and then select source. Set the projection to the proper projection and coordinate system for your location:


4.4 Installing and Setting up the GRASS Plugin

After the initial QGIS window has been opened and data has been added, next the GRASS Plugin. The GRASS Plugin allows the tools from GRASS to be used within QGIS.

• To add the GRASS plugin, select Plugins in the menu bar, then select Manage and Install Plugins in the drop-down menu.

• Search for GRASS in the search bar to install or if the plugin is already installed, it will be an option under the Installed column, select it here.

• After it is installed, the GRASS toolbar layer will appear on the user interface.

Grass plugin.jpg

4.5 Creating GRASS Database

• A GRASS Database is require to use these processes. Similar as a work space in ArcMap, except that a GRASS database MUST be stored all within a designated save location. To create the GRASS database, click on the New Map Set boxed in red.


• In the new map set browse to your existing directory or create a new one and then click next.


• To create the GRASS location, click on create new location and name it appropriately and click next.

• Setting up the projection, search or select the coordinate reference system using filter tool or by selection from the exiting. It is highly suggested to use the same projection as mentioned in section 4.3. Though some may be similar in fashion, keeping them congruent is the most efficient way.


• Set up the extent or the GRASS default region by clicking on: set current QGIS extent, also the default GRASS region N, W, E and E can be entered. Keep in mind the AOI (Area of Interest), because the workflow is based on Gatineau Park, the values should be appropriate to the AOI's geographic region.


• Finally create the GRASS new mapset by giving it appropriate name. Name the mapset appropriately.


Data Processing

5.1 Editing the Current GRASS Region

• Because map extents can be so large, they often take a little while to finish processing, it is suggested to set the extent to minimize processing time. To set the extent, click on the current GRASS region icon displayed.


• The settings window will pop up, there are two ways to set the extent, this can be done manually or by coordinates. Manually refers to drawing the AOI, while coordinates simply refer to furthest extents of each vortice in the AOI.


5.2 Importing Raster to GRASS Format

• To import a raster to GRASS area in question, click on the Open GRASS Tools


• When the below pops up, find File Management > Import Into GRASS > Import Raster Into GRASS > Import Raster Into GRASS From QGIS View. This will provide an series of redacted words. This is because a command series can be used to perform these operations in a program supported by python.


• The command series options looks as follows "r.in.gdal.qgis-Import loaded raster". Click the option, it will then prompt you to menu to import the desired raster. It is wise to have saved the raster in the GRASS workspace mentioned earlier as it will store all relevant data for this project in the same location.


• Then select the layer from loaded layer > give output name > Run. It is wise to name the imported raster accordingly as this may become confusing as there can be many iterations of the same data at different scales or elements in the future.


• The data is now stored within the added GRASS database, the original files can be removed, this can be done in the GRASS tool set for vector and raster data. Use ones discretion whether to delete the original data, it can often be useful to keep in the event there is an error or more iterations need to be performed, though it may cluster lists and data sets. This is why properly designating data sets with specificity is important.

5.3 Exploring Terrain Analysis Tools in the GRASS Modules

5.3.1 To run these tools.

• GRASS Modules > Raster > Spatial Analysis > Terrain analysis. There are a lot of Terrain Analysis tools available for various operations.If needed familiarize ones self with the different options. Here we are simply demonstrating the one process.


5.3.2 To create slope raster from DEM

• Select r. slope - "Create slope raster from DEM" from the Terrain analysis tool box.


• After the tool has been selected, select the DEM data from elevation raster map > name the output slope raster map > click Run.


• To view the map click on view output.


5.3.3 Creating Aspect Raster from DEM.

• Select r.aspect - create aspect raster from DEM from Terrain analysis tool box.

• After selecting the tool again, select the DEM data from elevation raster map > name the output slope raster map > click Run. As it is shown in the previous steps. 5.3.1 - 5.3.3


Sources of Error

• Many of the sources of error are user or administration based. This means understanding ones own nomenclature. Though this seams simple in this example, as more renderings are produced of the same area with different levels of scale, changing the resolution between each scale set and ensuring the analysis produced is not biased in any way. Bias' may include incorrect matching of DEM and Raster resolutions, a difference in projections, and so on.

• Know that many other sources of error do exist, those mentioned above only included user error and not error in the original data. This workflow assumes the original data is accurate before any analysis is conducted.


In this tutorial, learning how to use various Terrain Analysis Tools in the free and open source software of QGIS using the GRASS Plugin has been successfully demonstrated. The Raster Terrain Analysis Plugin can be used to calculate the slope, aspect, hill shade, ruggedness index and relief for digital elevation models. It is very simple to handle and provides an intuitive graphical user interface for creating new raster layers. This workflow is a preliminary understanding of the basic functions available with GRASS plugins, different types of manipulations as mentioned can be conducted easily under this platform. Many different sources of literature can be found online to provide more theoretical understanding into the processing methods and how to curtail the analysis process to develop different data sets as well as work around's. Below one can find some links to literature, they discuss various DEM processing and application methods. Additional "How To" links for Youtube videos have been linked for an in action use of the GRASS programs and plugins.


Download QGIS for your platform: http://qgis.org/en/site/forusers/download.html. [Web] accessed: Dec 22, 2015. GRASS GIS Integration: https://docs.qgis.org/2.8/en/docs/user_manual/grass_integration/grass_integration.html. [Web] accessed: Dec 22, 2015. QGIS Application : http://hub.qgis.org/projects/quantumgis/wiki/Adding_New_Tools_to_the_GRASS_Toolbox. [Web] accessed: Dec 22, 2015. DEM Raster Resolution and Order Sequencing : http://onlinelibrary.wiley.com/doi/10.1111/j.1467-9671.2004.00169.x/epdf. [Web] accessed Oct 18, 2017. Watershed Basin Analysis Using GRASS : https://www.youtube.com/watch?v=6BQltTwsU7A. [Web] accessed Oct 18, 2017.