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:

  1. Start QGIS.
  2. From the Plugins menu, select Python Console.
  3. We must import the processing module:
            import processing 
    
  4. Next, we run the dissolve algorithm specifying the input data 

Get QGIS Python Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.