Extracting Rasters with a Mask Layer

To limit the extent of your raster data, the Clip Raster by Mask Layer tool can be used to extract cells within your raster dataset based on the spatial extent of either another raster dataset or a polygon feature.

 

Included in this tutorial:

  • Utility of the Clip Raster by Mask Layer Tool

  • Accessing the Clip Raster by Mask Layer Tool

  • Inputs & Clipping a Raster

Software version in examples: QGIS-LTR 3.44.10-Solothurn

Tutorial Data: The tutorial includes demonstration with sample data available here.

Credits: Sally Kaye and L. Meisterlin (2026)

 

Utility of the Clip Raster by Mask Layer Tool

When working with raster layers, you often need to limit rasters to your study area.

  • Graphically, this is helpful when geoprocessing outputs extend beyond the relevant area.

  • Analytically, this is crucial when the range of values needs to be limited to those within your study area or when you must ensure that your rasters’ cells are aligned for map algebra.

Extracting rasters with a vector layer mask will, in effect, “clip” the raster so that it does not include those irrelevant cells (or cell values) beyond the mask. 

In the example below, the area within the red vector boundaries serves as our “example study area.” The problem is that the current raster (called “Points1_Kdens_DecB” in the screenshot) extends beyond the full scope of the study area.

setting up a raster to clip with a vector mask


Accessing the Clip Raster by Mask Layer Tool

To find the Clip Raster by Mask Layer tool, click through Raster in the menu bar > Extraction > Clip Raster by Mask Layer. 

Alternatively, you can find the tool in the Processing Toolbox by clicking through GDAL > Raster Extraction > Clip Raster by Mask Layer.

accessing the Clip Raster by Mask Tool through the menu bar and the Processing Toolbox


Inputs & Clipping a Raster

In the Clip Raster by Mask Layer dialogue box, you can specify parameters for clipping your raster.

viewing options and parameters in the Clip Raster by Mask Layer dialogue box

Here’s a brief description of the different inputs:

  • Input layer: The input raster from which cells will be extracted. (In our example, this is the “Points1_Kdens_DecB” raster layer.)

  • Mask layer: The input mask data defining the cell locations to extract. In other words, this layer’s boundaries serve as the clipping mask. In QGIS, this can only be a vector layer. (In our example, this data is the “Tracts_prj” polygon feature layer, symbolized in the screenshots with red outlines.)

  • Source and Target CRS [optional]: These parameters specify the CRS of the source (input layer) CRS and the output (Target) layer’s CRS.

  • Target extent [optional]: Use this parameter to specify the extent of the output raster layer. Click the arrow icon to set the output raster extent to the current map canvas extent, or use the dropdown arrow to set the extent to a layer or bookmark.

  • Assign a specified NoData value to output bands [optional]: This parameter allows you to establish the value for cells beyond the clipping mask layer but within the output raster’s extent. In the example below, we set this to 0.

  • Various Checkboxes

    • Create an output alpha band: Check this to create an alpha band in the output raster layer to store transparency values (usually in combination with R, G, and B bands).

    • Match the extent of the clipped raster to the extent of the mask layer: This option is useful if you do not specify the Target Extent (above). It will limit the extent of the output raster to the rectangular dimensions of the vector mask layer.

    • Keep resolution of the input raster or Set output file resolution: These two checkboxes allow you to either apply the resolution of the input raster layer to the output or indicate that you will specify a new raster resolution (cell size and dimension) for the output raster.

  • X and Y Resolution to Output Bands [optional]: If you chose to set the output file resolution (with the checkbox above), specify the resolution or cell size of your output raster with these parameters.

  • Clipped (mask): Choose whether to save the output raster as a temporary layer, or click the three dots icon to name and save the file for further use.

Click Run to run the tool.

running the Clip Raster by Mask Layer tool and viewing results

 
Previous
Previous

Reclassifying Rasters with a Table of Values

Next
Next

Calculating Zonal Statistics