Raster Analysis

Published

March 2, 2026

What are we going to learn?

In this workshop, we will learn about:

  • Rasters
  • Plugins
  • DEM
  • Terrain Analysis
  • Contours
  • Georeferencing

What is Raster Data?

A good example of a raster is an image file (like a jpg). If you zoom in on that image, you will see that it is just a grid of coloured pixels. Each pixel is just a cell with a number in it which tells the computer what colour it should be. The cell size might be small (high resolution), or large (low resolution).

A spatial raster is basically just a grid of cells like an image, but the values in those cells might represent the colours in an aerial photograph, or population density in that area, or the elevation. The main distinction of a spatial raster is that the grid is attached to a single coordinate point (usually in the top left corner), and the rest of the grid is laid on the map from there. The cells size of a spatial raster represents the distance each cell covers (for example they might be 1x1m or 10x10km).

Rasters aren’t as precise as vector data, as they are an approximation of the values in an area. For example every millimetre of a 1x1m cell might not have the same elevation, but the cell value is a helpful summary of the elevation in that area. This ability to neatly summarise and approximate data means that rasters are a very efficient way of showing continuous data across a large area.

A Digital Elevation Model (DEM) is a common example of raster data which shows the elevation of the land.

Aims for this session

In the last session we found that a number of residential areas will likely receive dust from the construction. One way to reduce dust is to regularly spray water on the roads, and wash down the trucks. However you now need to deal with the water runoff that creates. We can use watershed and basin analysis on a DEM to look at where the water will flow.

We can also use similar data to calculate how for away the wind turbines will be visible

Install the SAGA Plugin

We need to install a plugin so we can access certain geoprocessing tools (the built-in SAGA provider has been removed in version 3.30). Go to Plugins > Manage and Install Plugins... and Search... for “SAGA”. From the list on options choose Processing Saga NextGen Provider then in the bottom right, click Install Plugin. You might also need to install SAGA (version 9 or above) on your computer, if not already available.

If the SAGA tools still don’t show in the Processing Toolbox after installing the plugin, try the following on Windows / macOS (as suggested by the plugin developers):

  1. Get the SAGA 9.2.1 binaries (download ‘saga_9.2.1_x64.zip’ for Windows, or ‘saga-9.2.1_mac.zip’ for macOS)
  2. Unzip it
  3. in QGIS go to Settings > Options > Processing > Providers > SAGANG and point the SAGA folder to your unzipped folder

If that doesn’t work on Windows, and you have administrator rights, try installing SAGA with ‘saga_9.2.1_x64_setup.exe’ instead.

For Linux, use your distribution’s package manager to install it (e.g. sudo apt install saga on Debian-based). If the repository’s version is too old, consider adding an external repository that provides a more recent version (e.g. the UbuntuGIS PPA for Ubuntu-based distributions).

There are many other plugins from the QGIS Community that you can explore to enhance QGIS, but we will stick with this for now.

Load in our Raster data

  • Click the Project Home dropdown, then data > raw > 4-raster_data and load in:
  • Bris_DEM_5m.tif (From Geoscience Australia through their Elvis platform)

Reproject the DEM

In the Bris_DEM_5m layer’s Properties (Right click > Properties... > Source), we can see that the Coordinate Reference System (CRS) in use is EPSG:7844 - GDA2020. It is the one that QGIS detected when opening the file. While this is good for Australian data, we can’t do slope and terrain measurements and analyses while our raster is measuring in degrees, we need it projected to use metres. A good PCS for around Brisbane/Meanjin is “EPSG:7856 - GDA2020 / MGA zone 56”. We can’t change that here, we instead will need to use the Warp (Reproject) tool.

  • Use the tool Raster > Projections > Warp (Reproject)
  • Make sure Input layer is set as Bris_DEM_5m.
  • pick “EPSG:7856 - GDA2020 / MGA zone 56” as the Target CRS
    • if it is not in the list (ideally it would already be your “Project CRS”), you may need to click the Select CRS button image
    • untick No CRS
    • use the filter to search for “7856”
    • You should be able to find “EPSG:7856 - GDA2020 / MGA zone 56” under Predefined Coordinate Reference Systems
  • Scroll down to click the three dots ... next to the Reprojected field, navigate to the project’s processed data folder, and type in Bris_DEM_5m_reproj and click Save

If you want to learn more about the static datum GDA2020 (for “Geocentric Datum of Australia 2020”), an upgrade from the previous, less precise GDA94, head to the ICSM website.

Risks of Reprojecting Rasters

Important note: it is risky reprojecting Raster data, as this permanently changes the shape and structure of the underlying data.

Changing vector data from one Projection to another is straightforward, as you are just converting each point’s individual coordinates one-by-one. It’s just a numerical conversion. You can keep reprojecting vector data without issue.

When you reproject a raster, it will be in roughly the right location as the coordinate point in the top left corner will convert without issue. But because the raster is an interconnected grid, it will get stretched by the compromises made by the new projection. As we learned previously, the Mercator projection prioritises angles and direction, so converting to a Mercator projection might make your grid squares more rectangular. A projection like Albers Equal Area will prioritise area while distorting angles and shapes, so your raster might look very strange.

To make the data fit in this new shape, the reprojection process will use something called resampling. There are different resampling methods, but they basically overlap the old shape with the new one to determine what data fits in the new cells.

So what do you do?

Only reproject rasters when you must.

For example, if you are doing terrain analysis (such as slope), distance calculations, or spatial modeling that requires accurate measurement, you must reproject to a suitable projected coordinate system (not in degrees).

If you are analysing a raster with vectors, but your raster is in a different projection to your vectors, then reproject your vectors.

There are other exceptions, but if you’re unsure, check first.

Analyse Watersheds and Basins

Now that our raster is in a projected coordinate system, we can start doing measurements.

Using the Channel network and drainage basins tool, we can create layers with channels, drainage basins, and a watershed raster that shows where water would flow according to the DEM.

Fill Sinks

However before we can do watershed analyses we need to fix one more thing. A common problem with DEMs is that they have sinks and spikes that will make further analyses more difficult. This will mean the analysis is unable to best find where the water would flow. To resolve this, we need to use another tool to smooth out our raster before using the Channel network and drainage basins tool.

We can use the “Fill sinks (Wang & Liu)” tool to fill the sinks in our clipped DEM.

  • Open the Processing Toolbox by clicking the cog icon from the top menu Processing Toolbox
  • In the Processing Toolbox window Search for “Fill sinks (Wang & Liu)”
  • Double-click on the Fill sinks (Wang & Liu) option
  • ForInput layer choose Bris_DEM_5m_reproj
  • We might have to play with the “Minimum slope” value. A value of 0.01 degrees should work well.
  • As an output, we only need to tick the “Filled DEM” (first one in the list), which we can also save to file
  • Click Run

Channel network and drainage basin

Now we can use the Channel network and drainage basins tool to calculate the watershed, flow direction, channels and drainage basins.

  • Open the Processing Toolbox Processing Toolbox
  • Search for “Channel network and drainage basin”
  • Double-click on the Channel network and drainage basin tool
  • Make sure Input layer is the Filled DEM option.
  • We might have to change the threshold to a higher one if the output includes too many small basins and channels.
  • You will also need to tick the boxes of what you want it to output (see below), we will choose Channel, Junctions, and Drainage Basins.
  • Click Run

What are the different options:

  • Strahler Order: A Strahler Order raster that is used to classify stream hierarchy
  • Channels: Vector lines showing river paths with Strahler Order values.
  • Junctions: Vector points showing where channels meet.
  • Drainage Basins: Vector polygons delineating the areas that drain to the same point.
  • Drainage Basins [optional]: A raster version of the other Drainage Basins.
  • Flow Direction: A raster representing the direction of flow for each cell.
  • Flow Connectivity: A raster showing how well water could flow through sections of your map.

These are some examples of creating vector data from raster data!

We can now play with the symbology for those elements. For example:

  • Try using different colours for each basin, by classifying by ID, or remove the fill (Simple fill > Fill Style > No Brush) so you can see the colours of the elevation colours underneath. You can also make the borders more obvious by changing the width of the stroke.

  • Change the colour of the channels.

    • Change the symbol from “Single Symbol” to Graduated.
    • Set the Value to “Order”
    • Choose an appropriate colour ramp
    • Change the Mode down the bottom of the window to “Equal Interval”
    • Click Apply
  • You can also further differentiate minor channels from major ones by using a “Data defined override” for the Width value:

    • Click on the bar next to Symbol image
    • Click on the “Data defined override” icon image next to the Width field
    • Use the “Assistant”
    • “Source” needs to be the column “ORDER” (which corresponds to the Strahler order)
    • Click the double-arrow icon to “Fetch value range from layer”
    • Change the “Size from” and “to” values to suitable values

It is now evident that runoff from Enoggera Hill can flow into two different catchments: the Kedron Brook catchment, and the Enoggera Creek catchment (which itself runs into the Brisbane river), which matters when considering the project’s impacts.

To go further, we can play with our Drainage Basin layer to communicate better, for example by:

  • filtering to only show the two larger basins (for example: right-click on layer, click “Filter” and use the expression "AREA" > 3e7)
  • adding a “Name” column to the Attribute table, to then use them as labels
  • using different colours and some transparency to see what is behind, while making the borders thicker

Georeferencing an Image

  • Navigate to Layer > Georeferencer...
    • This will open the Georeferencer window
  • Go to File > Open Raster...
  • Open the raster_data folder and open QAP1592_6735-1693dpi.JPG

This should load a black and white image of Enoggera Hill on 13 August, 1964. This image is from QImagery, to make georeferencing easier, we have already rotated this image so that north is at the top (which isn’t always the case with historical images!).

We now need to set a few Ground Control Points (GCPs) to align the image. We create these by clicking a point on the image, and then an associated point on our basemap.

Make sure your World Imagery basemap is the top visible layer.

Use the Pan tool Pan tool icon to find similar points on the historical image and your basemap. Look for key terrain areas that will be consistent across the decades: fencelines, bridges, old buildings, large rocks, unqiue landforms, T-Intersections, etc.

Be careful putting points on tall buildings, as the photo angle can make that vary wildly - try aiming for a bottom corner.

When you want to add a point, change to the Add GCP Point Tool Add GCP Point Icon. Click to add a point on the Historical Image, in the pop-up click From Map Cavnas, and then the matching point on your Map. We will need at least 5 points spread throughout the map. As you add the points, you’ll see them appear in the GCP Table, higher residuals suggests that your points might not be lining up perfectly compared to each other. You want to try to be as accurate as you can, but you can’t be perfect.

To make this process easier…

  • Put the Georeferencer window on the right of your screen
  • Put the QGIS window on the left.
  • Press Ctrl + Shift + Tab to make the map full screen. Press those keys again to bring the toolbars back
    • CMD + Shift + Tab on Mac

Once you’ve added all your points, you need to open the Transformation Settings Transformation Settings Icon

  • For Transformation Type if you’re confident in all your points, choose Thin Plate Spline, if you’ve made some guesses or you have high residuals, go with Polynomial - it’s also much faster.
  • Choose where you want to save the output file
  • For Resampling Method it depends. Nearest Neighbour is faster, but generally not as accurate. Cubic tends to be more accurate, but it’s slow. Bilinear is a nice compromise.
  • Tick the Save GCP Points box. This means that after you georeference the image, if you decide you want to try again, you can reload the same points, and then remove or add some if you like.
  • Click OK
  • Click Start Georeferencing Start Georeferencing Icon

Soon you will have a Georeferenced Historical Image. Try turning the layer visibility on and off to see where it has skewed compared to your basemap. This can help you better see where you might be able to shift, remove, or add some more GCPs.

Here is the QGIS how to Guide for Georeferencing

Clip the DEM

If we want to focus on the terrain inside our Project Area, we can use Raster > Extraction > Clip Raster by Mask Layer.

  • Make sure the Bris_DEM_5m is selected in the Input layer
  • Set Mask Layer to Project Area
  • Scroll to the bottom and click the three dots ... next to the Clipped (mask) field, navigate to the project’s processed data folder, and type in EH_DEM_5m and click Save
  • Click Run

Change the symbology

We can style our DEM with a terrain colour palette:

  • double-click on the clipped DEM layer
  • go to the “Symbology” tab
  • change the Render type to “Singleband pseudocolor”
  • by default, it uses the min/max values, which is what we want
  • we can change the “Color ramp” to something more suitable with the drop-down menu and Create new color ramp... > Catalog: cpt-city > Topography > Elevation, for example.

Add a hillshade

Adding a hillshade makes your visualisation of elevation more readable and visually pleasing by giving an artificial lighting look to your map.

  • Go to Raster > Analysis > Hillshade...
  • Make sure the 5m_DEM is selected in the Input layer
  • You could change the lighting direction, angle and height exageration, but the defaults are fine.
  • Scroll to the bottom and click the three dots ... next to the Clipped (mask) field, navigate to the project’s processed data folder, and type in EH_DEM_5m_Hillshade and click Save

You can get the best of both by adding transparency to the DEM or the Hillshade.

  • Make sure the Hillshade is the above the DEM in the Layers panel.
  • Right click on you Hillshade layer, select Properties and then the Transparency tab
  • The best transparency will depend on your map and elevation, for this map, set the hillshade transparency to 5%.

Let’s link these two together.

  • Hold Ctrl and select both the Hillshade and the DEM layers
  • Press the Add Group button from the top of the Layers panel
  • Call it DEM
  • Make sure the DEM is above the Hillshade within this group

Contours

Adding a contour makes your elevation even more evident and can also be used to quickly show elevation on other layers

  • Go to Raster > Extraction > Contour....
  • Ensure the Input Layer is your clipped DEM “EH_DEM_5m”
  • For Interval between contour lines, the default is 10 m, which is good for this location. If you want to create finer the contour lines, it will take longer to process.
  • Scroll down to “Contours” and click “…” next to [Create Temporary Layer]“, then”Save to file”, and save it as EH_Contours_10m to your project folder.
  • Click Run

Viewshed

If you want to know what can be seen from a certain point in a landscape, or where in the landscape can see a certain point, you can use a DEM to perform a Viewshed Analysis. To be even more accurate, we can use a DSM instead - a Digital Surface Model. It’s very much like a DEM, but where a DEM has had the buildings and trees digitally removed, the DSM retains the heights of buildings and trees. This is useful for a viewshed, as it means that tall buildings might block the view in some areas.

In our case, we may be interested to know how far away people can see the wind turbines.

Open the Processing Toolbox Processing Toolbox and search for the GDAL tool called “Viewshed”.

Normally this tool is used from the perspective of what an Observer can see around them, but we can reverse this and have the wind turbine as the Observer. If they can see you, you can see them.

  • Input Layer: Choose your Bris_DEM_5m_reproj layer
  • Click the three dots next to Observer location to select a point on the map
  • Observer height, DEM units: 150 (this is the height of the centre of these wind turbines, it may be approrpiate to take into account the rotor length, but we’re keeping this simple)
  • Target height, DEM units: 1.6 (the average human eye height is around 1.6m, choose a height you think might be appropriate)
  • Maximum distance from observer to compute visibility: 15000 (5km is the distance you can see on flat ground due to the curvature of the earth, this changes as our “Observer” is much higher up, you can find calculators and a formula for this maximum distance. While you could theoretically still see the turbines from greater distances, their visual detectability begins to decrease).

This will produce a black and white raster showing what can be seen, and what can’t. Go to the Layer Styling Menu, and change it to Singleband Pseudocolor, change the Mode to Equal Interval, and set the Classes to 2. Change one of the Colors to transparent to highlight either where the turbines can be seen, or where they cannot.

If you want to get more sophisticated with your Viewshed analyses, there is, of course, a plugin called Visibility Analysis which will allow you to use one or multiple points as observers, take in account of the Earth’s curvature, see what vector points can see other vector points, and more.

Don’t forget to save your project