A common task in raster processing is clipping a raster with a polygon. This task is well covered by the Clipper tool located in Raster | Extraction | Clipper. This tool supports clipping to a specified extent or clipping using a polygon mask layer, as follows:
The extent can be set manually or by selecting it in the map. To do that, we just drag open a rectangle in the map area of the main QGIS window.
A mask layer can be any polygon layer that is currently loaded in the project or any other polygon layer, which can be specified using Select….
Tip
If we only want to clip a raster to a certain extent (the current map view extent or any other), we can also use the raster Save as ..., as shown in Chapter 3, Data Creation and Editing.
For a quick exercise, we will clip the hillshade raster using the Alaska Shapefile (both from our sample data) as a mask layer. At the bottom of the window, we can see the concrete gdalwarp command that QGIS uses to clip the raster. This is very useful...