Setting extents with masks

The extent of a layer can be set using a second layer, which acts as a mask. This recipe shows you how to do this.

How to do it…

To mask the DEM with the watershed mask, follow these steps:

  1. Open the watershed.tif layer and the dem.tif layer.
  2. Open the Raster Calculator algorithm present in the Processing Toolbox menu.
  3. In Main input layer, select the DEM, and in the Additional layers field, select the watershed layer.
  4. In the Formula field, enter the formula, a*b.
  5. Click on Run to run the algorithm. You will get a masked DEM, as follows:
    How to do it…

How it works…

When using the raster calculator, all operations involving a no-data value will result ...

Get QGIS: Becoming a GIS Power User now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.