Merging shapefiles

Merging shapefiles with matching projections and attribute structures is a very common operation. In QGIS, the best way to merge vector datasets is to use another GIS system included with QGIS, called SAGA. The OSGeo4W QGIS version for Windows includes SAGA. The KyngChaos distribution of QGIS for OSX includes SAGA. Most other versions and platforms will need SAGA manually installed. In PyQGIS, you access SAGA functions through the Processing Toolbox.

Getting ready

In this recipe, we'll merge some building footprint shapefiles from the adjoining areas into a single shapefile. You can download the sample dataset from the following URL:

https://github.com/GeospatialPython/Learn/raw/master/tiled_footprints.zip

Extract the zipped shapefiles ...

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.