Middelpunten verplaatsen (2)

If you want to influence the locations where labels, symbols or diagrams are displayed within areas, it is useful to have a separate layer with centroids. This article demonstrates how such a map layer can be created and modified in QGIS. The Dutch provinces are used as an example. This is a revised version of anĀ  earlier article (in Dutch), adapted to new possibilities in QGIS.

Calculate centroids

Open the shapefile for which the centroids should be calculated and make it visible. QGIS includes a function to generate a layer with centroids from a polygon layer. This function is accessible by selecting Vector / Geometry tools / Polygon centroids in the menu. Ensure the appropriate vector layer is selected (in this case the province map), choose a new name for the output file and click OK.

Confirm that the new layer must be added to the project and close the dialog. If the new layer is activated, the centroids will appear on the map. Ensure the regional boundaries remain visible as underlayer.

In the attribute table of the new layer you will see that all attributes of the original layer are present.

Move points

The points in the new layer can now be moved to more favorable locations within the areas. The safest option is to do this with a copy of the new layer. Just right-click on the layer in the left panel and select ‘Save as …’. The file type has to remain ‘ESRI Shapefile’. Add this new layer to the project and the operation can begin. First the toolbar ‘Digitizing’ must be made visible. This is most easily done by right-clicking on the menu bar. At first, most buttons on the toolbar will be disabled. After the pencil icon is clicked, the layer may be edited. Press the button with four triangles (“Move features’), in order to move points. Poorly placed points can now be dragged to the desired locations. It is possible to store results now and then, during the operation. When you’re done, click the pencil icon again.

If all three layers with area borders, original and shifted centroids are enabled, you can compare the result with the initial situation.

What next?

The layer with shifted centroids can later be used in different ways. Data may be linked to these points, with which symbols, pie or bar charts can be displayed. The centers can also be exported, by copying them from the attribute table to the clipboard, and pasting them into a spreadsheet. Suppose you create a text file from Excel, with regional data to be used in QGIS. It is advisable to always include the x and y coordinates. The advantage is demonstrated in an article about importing data (Dutch only).

Leave a comment

Your email address will not be published. Required fields are marked *