7.5.1. Vector to raster
The Vector to raster function rasterizes vector geometries into the band(s) of an existing or a new raster image.
- Go to Raster.
- Select Conversion.
- Choose Rasterize (Vector to raster).
- Choose the input shapefile (e.g. the layer commune_boundary_FR.shp) and
a suitable attribute field (e.g.
Be aware that any layer intersection (different features overlaying each other) cannot be transformed to raster data without data loss (in the intersecting areas).
- Specify an output raster file and a resolution in pixel value (Fig. 91).
- Launch the conversion by clicking OK.
The newly created raster image will probably be displayed in uniform grey colour. To apply different colours for the corresponding values (generated by the shape area of each polygon) proceed as follows:
- Open the Layer Properties.
- Select Style.
- Choose Single band properties.
- Select Colormap in the dropdown menu Color map.
- Switch to the tab Colormap and increase the number of entries, e.g. to 5.
- Click Apply.
- Navigate to the tab Transparency and make 0 values transparent (otherwise regions outside of the original polygon remain filled).
- Have a look at the changes on the Map View by clicking Apply.
- Close the Layer Properties
with OK, if the result looks similar
to Fig. 92.
Notice that the resolution of the polygon boundaries is coarse in the raster and not as smooth as in the original vector layer (zoom to the boundaries).
Fig. 91. Vector to raster conversion using QGIS.
Fig. 92. Symbolized raster image using 5 classes between blue (municipalities with small shape area) and red (largest area). Reproduced with permission of Swisstopo (BA13016).