Clipping rasters with QGIS

“QGIS provides various ways to clip a raster layer. In this worksheet we will look at one approach.”

If you have a raster that is larger than the area needed for your map or analysis, you can clip it to a smaller size using QGIS. In addition, you can 'mask' the layer using a polygon in order to assign no data values to pixels outside of your target area.

You try:

Goal: To determine the streams and catchment area for swellendam.

NB: You need the mentioned plugins

Data: SRTM

  • Load the raster from the data path
  • Run the fill sinks algorithm (save the filled demand flow direction only)
  • Apply the flow style to flow direction layer
  • Run the strahler alg and use the filled dem as input.
  • Use raster calc to create a bolean raster (userast calc expression and input raster is fromstrahler alg)
  • Apply the bolean style on the bolean raster
  • Add an additional no-data value 0 on the bolean raster
  • Run channels alg with Filled Dem as the input. Set the threshold to 8. (save channels and drainage basins only)
  • Activate plugins
  • Search Swellendam using geocode plugin
  • Zoom to a river near the point added by geocode plugin.
  • Use co-ord capture plugin to capture a point along the vector river.
  • Use the slope alg. Substitute x,y for values in the coordinate capture. Use values representing correct CRS of the raw raster layer.
  • Proceed to generate the catchment and streams as a vector layer.

Name Expectation

Fill sinks algorithm

Fill sinks (wang and liu)

Flow style


Strahler alg

Strahler order

Raster calc

"[email protected]" >= 7

Bolean style


Channels alg

Channel network and drainage basins


Coordinate capture,geocoding

Slope alg

Upslope area

More about Clipping rasters with QGIS

Raster data contains cells which are organised into rows and columns where each cell contains values representing information. Because raster images are generally very big and contain a lot of pixels (information), it is sometimes imperative to clip them. This can be achieved by either using a shapefile as a mask layer or by specifying an extent.

When clipping a raster layer we can change the other characteristics of the output layer like no-data values, spatial resolution and adding an alpha band to the output raster.

The spatial resolution of a raster defines the smallest possible feature that can be detected. No-data values are used to represent areas of a raster that have no data or areas in the raster that you do not want to show based on the pixel values in the raster.

An alpha band acts as a transparency mask, providing a transparency value for each pixel.

Check your knowledge:

  1. DEM is an abbreviation for:
    1. Data emission problems
    2. Digital elevation Movie
    3. Digital elevation model
  2. Which of these represents a derivative of a digital elevation model:
    1. A satellite image showing mountanous areas
    2. A slope curvature map that is used by surveyors to determine the direction at which the sun shines
    3. A vector data that represents natural phenomen
  3. Plugins are extensions in QGIS:
    1. True
    2. False

Further reading:

Click here to download the sample data for the lesson.