Use QGIS to export shapefile as raster to use as mask

exportqgisrasterizationshapefile

I have a shapefile that is a set of polygons. I would like to export it as a black and white image to use as a mask. I'm not incorporating height data (the shapefile only holds 2D data), but encoding whether a pixel is part of a polygon or not so that I get a replica of the spatial layout of the polygons in a raster image.

How would I do this in QGIS? I cannot find an obvious path.

Best Answer

If I understand your issue: I would use the Rasterize (Vector to Raster) algorithm in the processing toolbox. Set your polygon layer as the input. Set the burn in value to 1. Set your desired pixel size in georeferecnce units, and your desired extent etc. This will result in a layer that has 1 as the values in the polygon areas and nodata in all other cells. If you want to have 0 in the other cells use the advanced section and set the pre-initialization value to 0. You may also have to set the nodata value to something like 255. enter image description here

Related Question