2

I was reading the QGIS Python Programming Cookbook (page 74) trying to learn how to merge shapefiles because I need to do it for what I'm doing. I was using their example just to try it out though.

I would like to know if there's any way to merge all the shapefiles in a folder together to make one shapefile.

Theses are the files in my folder:

footprints_ne.dbf
footprints_ne.shp
footprints_ne.shx
footprints_nw.dbf
footprints_nw.shp
footprints_nw.shx
footprints_se.dbf
footprints_se.shp
footprints_se.shx
footprints_sw.dbf
footprints_sw.shp
footprints_sw.shx

And this is my code:

import os
import glob
import urllib
import sys
import zipfile
import processing


pth = "C:/Users/myself/Desktop/qgis_data/tiled_footprints/"

files = glob.glob(pth + "*.shp")

out = pth + "merged.shp"

processing.runandload("saga:mergeshapeslayers", files.pop(0), ";".join(files), out)

For some reason it gives me an error complaining about my algorithm but I'm just following the book. I am new to programming.

nmtoken
  • 13,355
  • 5
  • 38
  • 87
  • And the error is? – John Powell Jun 15 '16 at 07:13
  • 1
    Which QGIS and Processing plugin version are you using? In the latest versions, the algorithm is now currently called saga:mergelayers. The parameters for this have also slightly changed: [input, source info, match field names, output]. So you should probably use something like: processing.runandload("saga:mergelayers", files, True, True, out) – Joseph Jun 15 '16 at 08:59

0 Answers0