02 February 2014

QGIS basic tutorial 2 - merging administrative divisions

Let's analyse a situation, you have a data set and you have something, what looks like the matching shape file, you think cheerfully that the data set will fit to the shape file like a hand to the glove. Unfortunately, life isn't so easy. Some shape files aren't updated regularly, it is common that administrative districts with low population density are joined to the neighbouring districts. It is worth to compare the number of districts in your data sets with the shape file. If you see any gap, try to find information about changes, so you will know which districts should be merged.

1. Merging districts on the map 
If you know where the districts, that should be joined, are placed on the map, you can work from the map level.

Use the icons to navigate to the districts.

Select the districts, there is a variety of options, so I give you choice ;)
If you use 'Select Single Feature' to highlight more than one press Ctrl.

The districts waiting to merge are highlighted.

Select the 'Toggle Editing' icon

 ...or right-click on the layer,

...or upper menu: Layer => 'Toggle Editing'.

 If your 'Toggle Editing' icon is inactive, it is a sign that you forgot to select the layer.

Now icon 'Merge Selected Features' is active and you can click it.

Edit the attributes of the new district.


2. Merging districts in the attribute table 
If you don't know where the districts that should be joined are placed on the map, but you have found their names on the website of the local Statistical Office or any other source of information... you can browse for them on the attribute table and then to place them next to each other click on the icon 'Move selection to top'.

If the file is big and scrolling down the attribute table in search for the districts takes too much time, you can use all filtering and selection options which I described here.

Continue just like above, use the merge-steps which are between the stars :) ****

3. Geoprocessing Tools => Dissolve 
You can also merge administrative districts using the fields from the attribute table. Hard to explain but easy to do so just check the example :)
For instance we can join the second level of administrative divisions to receive the first level divisions.
We start with:

Then Vector => Geoprocessing Tools => Dissolve

 'Dissolve field' is a key which groups the districts that should be joined together (in this example it can be ID_1 or NAME_1 as it is unique for each first level of administrative district).
Browse to find a place for your newly created shape file and give it a name.

'Would you like to add the new layer to the TOC?' Yes :)
The map is ready.


There are some dots inside the polygons, if you plan to use this shape file in Tableau you can just ignore them, as Tableau won't see them. If the dots are too annoying to you and you can't just leave them, you should use activate 'Delete Ring' and then click on each annoying dot...

Here is the evidence that ignoring the dots is not a problem for Tableau.


The new attribute table consists the columns which were describing second level of administrative districts so now they aren't correct and we have to delete them by activating 'Toggle Editing' and then 'Delete column'.

No comments:

Post a Comment