Book Image

QGIS Python Programming Cookbook

Book Image

QGIS Python Programming Cookbook

Overview of this book

Table of Contents (16 chapters)
QGIS Python Programming Cookbook
About the Author
About the Reviewers

Dissolving vector shapes

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.

Getting ready

Download the GIS census tract shapefile, which contains tracts for several counties from

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, as follows:

  1. Start QGIS.

  2. From the Plugins menu, select Python Console.

  3. Import the processing module:

    import processing
  4. 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: