QGIS – Mask a Raster Tile

  • Updated

by David Crowther



Is it possible to set a Mask around Raster Tiles in QGIS?


Masks are commonly used to allow the end user to better interpret the map being shown to them. For example, using an inverted polygon boundary you can mask all layers that fall outside your area of interest – so that users only see the information that is important to them!


See this Cadline Community blog for more details:


The same idea can be applied with Raster tiles, where you could simply use the same vector inverted polygon to mask the raster layer that falls outside of the polygon – this could be useful for printing purposes.

However – you can also clip the Raster layer using the mask polygon to create a new tile that only includes the raster tile within the clip polygon area. Below we have one Raster tile – TQ0057 and a Mask Polygon called – SchoolPolygon.


You can choose to clip the raster tile using the map extents, or by using a Mask Layer, such as the SchoolPolygon.

We will choose the second option, so from the menu Raster > Extraction > choose > Clip Raster by Mask Layer…


Choose the input raster tile and the mask polygon layer, and set the Source CRS as needed – e.g. 27700.


Then choose to output the result to a new File, saving the tile with a new name and choosing the image type e.g. .tif


Once ran it creates a new raster tile, showing only the area that falls inside the mask polygon. However the area around the edges of the tile, that fell outside of the Mask polygon are coloured as black pixels.


This time, when you run the routine, tick the option to Create an output alpha band, in addition to the pre-ticked option to match the extent of the clipped raster to the extent of the mask layer.


Once you run this again, the output clipped raster tile, will have the areas outside the mask polygon changed to white, which now shows the clipped Raster tile as we would need it.


If you tick to show the clip Mask layer – SchoolPolygon – we can now see that our image was correctly clipped using the Mask layer.


Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request



Please sign in to leave a comment.