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.

  1. Go to Raster.
  2. Select Conversion.
  3. Choose Rasterize (Vector to raster).
  4. Choose the input shapefile (e.g. the layer commune_boundary_FR.shp) and a suitable attribute field (e.g. “Shape_Area”).
    Be aware that any layer intersection (different features overlaying each other) cannot be transformed to raster data without data loss (in the intersecting areas).
  5. Specify an output raster file and a resolution in pixel value (Fig. 91).
  6. 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:

  1. Open the Layer Properties.
  2. Select Style.
  3. Choose Single band properties.
  4. Select Colormap in the dropdown menu Color map.
  5. Switch to the tab Colormap and increase the number of entries, e.g. to 5.
  6. Click Apply.
  7. Navigate to the tab Transparency and make 0 values transparent (otherwise regions outside of the original polygon remain filled).
  8. Have a look at the changes on the Map View by clicking Apply.
  9. 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.

figure091


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).

figure092