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 explore ways in which to clip rasters acoording to AOI.

Clip by Extent

  • Load the raster layer into QGIS.
  • Navigate to the Raster Menu > Extraction.
  • Select Clip by Extent. Populate the dialog using the Clip by extent options.
  • Using this tool, how would you produce an irregularly shaped raster as output?
  • Remove the clipped raster from QGIS.

Clip by Mask

  • Load the two vector layer to QGIS.
  • Create an intersection layer between the settlement and boundary layer.
  • From the resultant intersection layer select the polygon with the SP_Name Marloth Nature reserve SP
  • Navigate to the Raster Menu > Extraction.
  • Select Clip by Mask. Populate the dialog using the Clip by mask options.
  • Toggle visibility for all the layers leaving the resultant layer from the clip.
  • Why is there a black colour around the output image.
  • Repeat the clip procedure using the Clip by mask options and an additional option no-data value set to 0
  • Compare the two clipped output layers. What can you infer about the two outputs ?

Additional Question

How can you clip the raster layer to match each row in the intersection layer? If you wanted to generate a raster for each polygon from the intersection layer.

Name Expectation

Clip by extent

 

Clipping Extent

Draw on Canvas

Creation options

High Compression

Clip by mask

 

Mask Layer

Intersection with the option selected features activated

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 mountainous 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 phenomena
  3. Plugins are extensions in QGIS:

    1. True
    2. False