Dissolving vector features
Dissolving a group's geometry allows you to produce a single geometry with common attributes. In this recipe, we'll dissolve some census data into a single dataset.
Getting ready
Download the GIS census tract shapefile, which contains tracts for several counties from the following URL:
https://github.com/GeospatialPython/Learn/raw/master/GIS_CensusTract.zip
Extract it to your /qgis_data directory in a directory called census.
How to do it...
We will use the processing toolbox for this recipe and specifically a native QGIS algorithm called dissolve:
Start QGIS.
From the Plugins menu, select Python Console.
We must import the
processingmodule:import processing
Next, we run the dissolve algorithm specifying the input data
Falseto specify we don't want to dissolve all shapes into one but to use an attribute instead, the attribute we want to use, and the output file name:processing.runandload("qgis:dissolve","/qgis_data/census/ ...