In section 7.4.2., a definition query was set from the polygon layer representing different municipalities within the canton of Fribourg (Fig. 85). To aggregate all features that contain the same attribute “KANTONSNR” by producing a vector layer of all districts, the Dissolve function is a good option (see section 6.5.7. for further explanation about the dissolve tool):
- Open the Query Builder for the polygon layer you want to use by right-clicking.
- Make sure that no restriction is made within the SQL “where clause” (If you use the layer commune_boundary_FR.shp, delete the entry "KANTONSNR" = 10, if this still exists).
- Confirm with OK.
- Go to Vector.
- Select Geoprocessing Tools.
- Choose Dissolve.
- Locate the layer commune_boundary_FR.shp as Input vector layer.
- Leave the checkbox Use only selected features blank (with this the operation could be performed on a selection of features only, but in our case no selection has to be applied).
- Select an attribute (e.g. “BEZIRKSNR”) as Dissolve field.
- Choose a path and name for the destination file to be created (Fig. 98).
- Finish by clicking OK.
Now the whole canton of Fribourg is selectable at once (representing only one line within the Attribute table), and the “island polygons” in the north-western part demonstrate what is meant by a “multipart polygon”. What happened to the attributes? – Of course some of the attributes are no longer thematically correct: the dissolve function allocates the attributes from the first line of each value that was aggregated. The display of the new layer can be improved:
- Open the Layer Properties.
- Select Style.
- Set a categorized symbol style with different fill colours for all 5 districts (by using the column “BEZIRKSNR”).
- Choose a colour ramp.
- Click Classify.
- Apply the changes.
- Close the Layer Properties dialog by clicking OK.
- The result will look similar to Fig. 99.
Fig. 98. Dissolving polygons by the attribute “BEZIRKSNR”: The new layer will contain aggregated polygons based on this attribute.
Fig. 99. After applying the Dissolve tool, the polygon layer is divided into 5 different districts. The thin black lines on top represent the former state (51 different municipalities. The yellow circles were created using a radial buffer of 2000 m around of all the honey bee colony locations. Reproduced with permission of Swisstopo (BA13016).