Dissolving shapes can take two different forms. You can combine a group of adjoining shapes by the outermost boundary of the entire dataset, or you can also group the adjoining shapes with the same attribute value.
Download the GIS census tract shapefile, which contains tracts for several counties from https://geospatialpython.googlecode.com/files/GIS_CensusTract.zip.
Extract it to your /qgis_data
directory, in a directory called census
.
We will use the Processing Toolbox for this recipe and specifically a native QGIS algorithm called dissolve
, as follows:
Start QGIS.
From the Plugins menu, select Python Console.
Import the
processing
module:import processing
Next, run the
dissolve
algorithm, specifying the input data—False
to specify that we don't want to dissolve all the shapes into one but to use an attribute instead—the attribute we want to use, and the output filename:processing.runandload("qgis:dissolve","/qgis_data/census/GIS_CensusTract_poly...