A multi-criteria raster analysis with QGIS 3

000 titelbild
Bild CC BY-SA 4.0 Paul Hermans. (Quelle: https://commons.wikimedia.org/wiki/File:Gemse01.JPG)

Allgemeines

Do you know where chamois potentially live? A multi-criteria raster analysis with a GIS provides the answer. This exercise was originally done by Andreas Lienhard, Kanton Zürich (many thanks!), and it will be continuely developed.

  • Time required: This exercise takes at least 30 minutes if you already have some fundamental QGIS knowledge.

  • Prerequisites: QGIS 3 (this exercise was created with QGIS version 3.6 and tested with QGIS 3.4 LTS).

  • Keywords: GIS, raster, grid, multi-criteria analysis, raster algebra, QGIS.

Goals and Templates

The goal of this exercise is to use multi-criteria GIS analysis to find out where chamois potentially have their habitat. To do this, we make the following assumptions (criteria):

  1. Chamois stay mainly above 1500 m (above sea level). We also look for chamois in spring when there is still a lot of snow above 2500 m.

  2. Chamois are mainly found on steep slopes (slop > 20%).

  3. Chamois prefer warm slopes that are dried out early, i.e. southern slopes.

  4. Chamois use alpine pastures, because in spring there are no cattle on the alp yet.

The following two raster / grid data sets are available for analysis (More information on the ASCII grid format is available here http://giswiki.hsr.ch/Grid):

  • Elevation model “DHM-Rimini” (originally from Swisstopo) in ArcInfo-ASCII-Grid-Format, file dhm_rimini.txt.

    (Elevation model: English Digital Height Model, DHM)

  • Statistics data “Arealstatistik 85” (originally from BfS) in ArcInfo-ASCII-Grid-Format, file as85.txt contains land cover types such as wad, meadows and pastures.

Preparations

After the specifications have been clarified, we can start analyzing the potential chamois habitats. This is the schedule:

  • First load the elevation model and the area statistics to the QGIS.

  • With the elevation model, a hill-shading map is generated as a pure background in advance.

  • With the elevation model, an slop map and a terrain alignment map are calculated and saved as intermediate results.

  • Then partial results are calculated and saved according to the four criteria:

    • Based on the elevation model, the corresponding elevation areas are filtered.

    • The steep slopes are filtered based on the slope map.

    • The southern slopes are filtered based on the orientation map.

    • The alpine pastures are filtered based on the area statistics.

  • Finally, the last four intermediate results are intersected with each other (spatial overlay, intersection) and the result is visualized.

Now start QGIS or open a new QGIS project → change the project’s coordinate reference system at the bottom right to the old Swiss coordinate reference system EPSG: 21781.

Import

In order to load the two input files as85.txt and dhm_rimini.txt, you can either drag them into the QGIS with “Drag & Drop”, or you can open the Layer  Add Layer. There you select the Add raster layer… and enter the appropriate files. Select the coordinate reference system EPSG: 21781.

Check the “dhm_rimini” layer at the top and visible in the Layer Manager, otherwise just drag the layer up in the Layer Manager. If the layer is displayed in black, you can adjust it by going to Layer Properties and change from Clip to MinMax to Stretch to MinMax under Contrast Enhancement (there are a few more display options). You should now see something like below.

00 geladen

Terrain hillshade map

This step is not yet part of the evaluation but rather serves for visualization and orientation on the map. The raster layers can be edited and changed in QGIS via the menu Raster. In most cases, new layers are created and displayed in the QGIS project.

01 menu

In order to be able to generate a terrain hillshade map from an elevation model, select Menu Raster  Analysis  Hillshade (see figure below).

01 schummerungskarte 01 schummerung protokoll

As the input file you choose the layer “dhm_rimini”. In "Hillshade" (output file) right click on …​, open a new exercise data folder e.g.games and enter the name gelaende.tif (the extension tif stands for TIFF or GeoTIFF).

After a click on Start, the dialog window automatically changes to the tab with the execution log. You can then close the "Hillshade" window with the log. Then you should get something like the following result with the hillside terrain:

01 schummerungskarte bsp

At this point, save the entire QGIS project in the folder e.g. games with the name games.qgz.

02 perspective

Now in the next chapter we come to the first evaluation with the partial result “Terrain orientation”.

Terrain alignment map

The terrain orientation map shows the aspect of the terrain in relation to the north. It is created with an elevation model as the source via the Raster  Analysis  Aspect (see figure above).

As the input layer you choose “dhm_rimini” again. In “Aspect” (output file) select the exercise data folder (games) and the file name aspect.tif: see figure above.

If everything went right, you should see something like this (can also differ):

02 perspective bsp

We now want to improve this representation of the terrain alignment map a little. To change the style of a layer, you can right-click or double-click the layer name and its properties.

Select in Symbology in the first entry Band Rendering the Render type Singleband pseudocolor. As a Band you only have the Band 1 (gray) option available. Now you can set Min to 0 and Max to 360, Interpolation to Linear, choose any Color ramp so that the automatic classification works (color gradient does not matter, since we use the manually assigned colors), the Mode on Equal interval and the number of classes on 5.

An orientation map contains an angle (in degrees °) as a value, which represents the orientation of the terrain. We want to assign different colors to the four main directions (N, E, S, W). In the result of the operation used, 0° corresponds to north (N). With values close to 0 ° it is a north slope. But values close to 360° also represent north-facing slopes. That is why five classes were used instead of just four. Therefore same color is assigned to the first and last class, e.g. blue. The angle in the result is to be understood as clockwise, so 90° means east. Assign different, easily distinguishable colors to the remaining three classes, e.g. red, yellow, green.

If you want, you can give the classes a meaningful “label”, e.g. N, O, S, W (and again N).

02 perspective colors

When you have made all the settings, go to the Transparency (below Symbology). Here we set the global transparency to e.g. 50%, so that you can still see the hillside shading under the colored alignment map.

02 perspective transparenz

Then click on Ok (the dialog window closes).

The result should now look something like the picture below. If you have set other colors, that doesn’t matter. The main thing is that the cardinal points of the mountain slopes now can be visualized with different colors.

02 perspective final

Slope map

With the function Slope (Raster  Analysis  slope) shows the incline of a terrain as raster/grid. For this exercise we want to express the incline in percent instead of degrees (see below). Select the “dhm_rimini” layer again as input file and save the output as slope.tif in the exercise folder. Then Run.

03 slope inked

The result looks like this (with Contrast enhancement on Stretch to MinMax):

03 slope bsp

Filter according to the criteria

You have now prepared the data and we can apply the criteria. Reminder: We are looking for those areas that meet the following criteria:

  1. Areas that are higher than 1500 m and lower than 2500 m (above sea level).

  2. Areas steeper than 20%.

  3. South-slope areas, i.e. areas that are oriented from southeast to southwest.

  4. Areas that are used for meadow and arable land, home pastures, mountain pastures, hay pens, mountain meadows, and alpine pastures.

In order to meet these requirements, we now calculate four more layers from the prepared data. A blend of this will show us where chamois could be. The blending and the filtering is done with the “Raster algebra” and in QGIS with the raster calculator.

Let’s start with the first criterion: The heights of the terrain are stored in the layer “dhm_rimini”. We will now calculate a new layer that only contains those grid cells that are between 1500 and 2500 meters (above sea level). To do this, you have to open the RasterRaster calculator.

04 rasterrechner menu

In the grid calculator you have to enter the output layer in the top right corner again. Select the exercise folder and name the output file dhm_rimini_1500_2500.tif.

05 dhm rastercalc

The available layers are listed on the left in the dialog with their Raster bands (here always “@1”). For this first calculation we choose “dhm_rimini@1”. By double-clicking on it, it can be added to the raster calculator expression in quotation marks. But the printout is not ready yet. We would like to filter for values between 1500 and 2500. To do this, we select the operators “greater than or equal to” / “less than or equal to” (> = and \ ⇐), which we combine with AND and brackets. This returns those values that are in between a 1. But we actually want to keep the original value of these. To do this, we multiply the parenthesized expression by the original value itself (that’s skillful, because the parenthesized Boolean expression is obviously interpreted as the number 1/ 0 instead of true/ false). You can either type in the expression directly or compile it by clicking on the operator buttons in the Operators area. Start the Raster calculation with OK.

05 dhm rastercalc bsp

We can now check whether all the desired points have retained their value by clicking on query objects (the “i” icon) and clicking the window with the mouse: Value 0 is displayed for black raster cells (pixels) and a value between 1500 m and 2500 m (Above sea level) for gray ones .

In order to filter the 0 values out of the view, we can assign a transparency to them. In the Layer Properties Transparency and Custom Transparency Options you click on + and set the two values From and After to 0 and Percentage transparency to 100 percent. Then click Apply.

05 dhm rastercalc bsp transparenz

Now switch off the visibility of the "Slope" layer in the Layer Manager. The result is now filtered so that you can see the other layers below:

05 dhm rastercalc bsp transparenz bsp

Repeat the same steps - first Raster calculator then Transparency - you now apply for all three other criteria, as follows:

For the second criterion you start from the layer or band “slope@01” and save the result in the exercise folder under the name slope_over20perc.tif (Ok is not yet activated). In this case, use the grid calculator to select all grid cells that are steeper than 20%. Then Ok.

For the third criterion you use the layer “Aspect” (` aspect.tif`) and filter out all grid cells that are between 135 and 225 degrees (i.e. 180 degrees plus/minus 45 degrees). This will give you all south-facing slopes (north is 0 ° as a reminder). Save the result in the exercise folder under the name aspect_135_225.tif. Then Ok.

For the fourth and last criterion we use the layer “as85”. The different types of terrain are stored in this as a code (integer). We are only interested in all those areas that have the following uses: meadow and arable land, home pastures, mountain pastures, hay meadows, mountain meadows, alpine and Jura pastures. These correspond to codes 8, 9, 10 and 11. Therefore filter the layer “as85” for these codes. Save the result in the exercise folder under the file name as85_sorted.tif.

Remember to set the Custom Transparency to 100 percent for the values from 0 to 0 for each layer (see layer properties).

Try this out for all of the steps. If you get stuck, each step is described in the next chapter with a solution and screenshots.

You have now made all the necessary preliminary calculations. Now you have to intersect the four layers (overlay / intersection). To do this, you use the Raster calculator again and combine the four layers “dhm_rimini_1500_2500”, “slope_over20perc”, “aspect_135_225” and “as85_sorted” with the logical AND operator. Name the result gut_fuer_gaemsi.tif and save it again in the exercise folder. Again, you should set the custom transparency to 100 percent for the values from 0 to 0.

If you want, you can also color this result with a button click on single-band pseudo-color or palette:

09 gut fuer gaemsi bsp

Now we know where the chamois presumably “live”! At least according to our data and assumptions.

We are now satisfied with this exercise. However, there are still some space for improvement, on one hand for better readability (e.g. important places, streets and mountain peaks) and on the other hand for better analyzes. For example, where the raster cells could be converted into vectors in order to be able to link the polygon results with further data.

Detailed instructions

This chapter is a supplement to the previous chapter in which only the first criterion was explained in detail.

To calculate the three other criteria, we proceed in the same way as with the first criterion. That means we first use the raster calculator and then set the transparency of the unnecessary values to “transparent”.

Second criterion (areas that are steeper than 20%):

Open the Raster Calculator, select the Raster band “slope@1” and enter the following Raster calculator expression:

("slope@1"> 20) * "slope@1"
06 slope 20percent

Then set the transparency for the layer.

The result of the second criterion should look like this:

06 slope 20percent bsp

Third criterion (southern slope):

In the Raster calculator, set the Output layer aspect_135_225.tif, select the raster band “aspect@1” and enter the following Raster calculator expression:

("aspect@1" > = 135 AND "aspect@1" <= 225) * "aspect@1"
07 aspect south

Then set the layer transparency. The result of the third criterion (one-band pseudo-colors copied from “Aspect”) should look like this:

07 aspect south bsp

Fourth criterion (types of terrain):

In the raster calculator you select the raster band “as85@1”, the output layer as85_sorted.tif and enter the following raster calculator expression:

("as85@1" >= 8 AND "as85@1" <= 11) * "as85@1"
08 as sorted

The result of the fourth criterion is shown below (palette colors and also with transparency):

08 as sorted bsp

Others:

Last but not least, we calculate the chamois locations with a intersection (spatial overlay) and save this under gut_fuer_gaemsi.tif. Here is the solution for the Raster calculator expression:

"dhm_rimini_1500_2500@1" AND "slope_over20perc@1"
AND "aspect_135_225@1" AND "as85_sorted@1"
09 gut fuer gaemsi

The result is shown at the end of the previous chapter.