Skip to main content
Completion requirements

2. Load and Prepare the Layer with Municipalities

Let's start with loading the data.

1. Open QGIS Desktop with a new project.

2. Install the PDOK Services plugin from the Plugins Manager.

3. Click the PDOK Services  icon in the toolbar.

As you can see the PDOK Services plugin gives access to thousands of open data layer for the Netherlands. They are available through different OGC services (WMS, WFS). This includes high resolution digital elevation models (AHN) and aerial photographs for example. Here we'll need to look for the WFS layer with recent statistics for municipalities. WFS, because we need to have the vector data. Remember that WMS only gives a rendered picture and not the data.

The interface is in Dutch, but you'll understand it quickly using the following steps.

4. At Zoeken (search in English) type:

gemeenten wfs

Gemeenten means municipalities.

In the box at the bottom the metadata is presented. It shows that the layer contains the 2021 statistics from Statistics Netherlands (CBS).

5. At Laag toevoegen (Add layer in English) click Standaard to add the layer to the Layers panel. Click Close to close the dialog.

Now it will start drawing the map with municipalities with a random fill color.

This layer contains the polygons of municipalities with and without water bodies. For the visualization we only need the boundaries without the water bodies.

The layer is large, so it's better to not open the attribute table now to check the fields. Instead we'll use the Layer Properties.

6. In the Layers panel, right-click on the gemeenten layer and choose Properties... from the context menu.

In the Fields section at the Information tab you can see the fields in the attribute table.

There's a field named water. We can use that to select the polygons that don't include the water bodies. We will later calculate the number of people per household. Then we'll use the aantalInwoners (number of inhabitants) field and the aantalHuishoudens (number of households) field.

7. Click Cancel to close the dialog.

8. Click the black arrow next to the icon in the Attributes toolbar and choose Select Features by Expression from the drop-down menu. We're using this instead of opening the huge attribute table.

9. In the Select by Expression dialog expand in the middle panel Fields and Values and click on water. In the right panel click All Unique and wait for the result.

The water field in the attribute table contains the values B, JA and NEE. Obviously NEE means No and we need to select those features.

10. Double click on water to add it to the Expression. Then click the equal button and double-click on NEE to add it to the Expression.

The expression should now read:

"water" = 'NEE'

Note the double quotes for field names and the single quotes for strings.

11. Now click Select Features to select the polygons without water bodies.

12. Click Close to close the dialog.

The selected municipalities are now highlighted in yellow in the map canvas.

Now we can export the selected polygons from the WFS layer to a GeoPackage, so we can easily use it in further calculations.

13. In the Layers panel right-click on the gemeenten layer and choose Export | Save Selected Features As... from the context menu.

14. Save the layer to a GeoPackage with the name municipalities.gpkg in the folder on your hard drive that you'll use for this project. Give the layer the name municipalities without water.

15. Click OK to export the layer and load it into the map canvas.

16. Remove the gemeenten layer from the Layers panel (right-click and choose Remove Layer... from the context menu and click OK to confirm).

Now our layer is ready for calculations and styling. Don't forget to regularly save your projects. You can save the project in the GeoPackage to keep everything together.