I have a few thousand polygon shapefiles in a folder that I would like the SAGA Split Features Layer tool to perform its operation on. The operation and parameters are the same for every polygon, but just can't get it to iterate across the files. Below is the result I want.
Error:
exec(open('C:/GIS Data/ab_grids/feature_split.py'.encode('utf-8')).read()) Traceback (most recent call last): File "C:\OSGeo4W\apps\Python39\lib\code.py", line 90, in runcode exec(code, self.locals) File "", line 1, in File "", line 11, in File "C:\OSGeo4W/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 108, in run return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context) File "C:\OSGeo4W/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 183, in runAlgorithm raise QgsProcessingException(msg) _core.QgsProcessingException: Unable to execute algorithm Could not load source layer for SHAPES: invalid value
# split twp grid into 2x2 grid
import processing
import glob
import os
# folder where polygons are stored
source = "r'C:\GIS Data\ab_grids\twp_polygons'"
files = glob.glob(source + "*.shp")
output = "r'C:\GIS Data\ab_grids\twp2_2'"
processing.run("saga:splitfeatureslayer",
{'SHAPES':files,
'CUTS':'TEMPORARY_OUTPUT',
'EXTENT':output,
'NX':2,
'NY':2,
'METHOD':0})