I try to use the processing 'qgis:extractbylocation' in QGIS 2.8.2 from the QGIS algorithm provider.
import processing
# import the layers by a given uri
inputlayer = QgsVectorLayer(uriTr.uri(), "inputlayer", "postgres")
intersectlayer = QgsVectorLayer(uriOSM.uri(), "intersectlayer", "postgres")
# initialize a predicate instance
pred_intersects = processing.core.parameters.ParameterGeometryPredicate(enabledPredicates = 'intersects')
# run the processing
processing.runalg('qgis:extractbylocation', inputlayer, intersectlayer, pred_intersects, None)
However I get the following error:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "~/.qgis2/python/plugins/processing/tools/general.py", line 71, in runalg
alg = Processing.runAlgorithm(algOrName, None, *args)
File "~/.qgis2/python/plugins/processing/core/Processing.py", line 317, in runAlgorithm
if not param.setValue(args[i]):
File "~/.qgis2/python/plugins/processing/core/parameters.py", line 829, in setValue
elif len(value) == 0:
AttributeError: ParameterGeometryPredicate instance has no attribute '__len__'
The algorithm needs the following inputs
processing.alghelp("qgis:extractbylocation")
ALGORITHM: Extract by location
INPUT <ParameterVector>
INTERSECT <ParameterVector>
PREDICATE <ParameterGeometryPredicate>
OUTPUT <OutputVector>
ParameterGeometryPredicate is described here: https://fossies.org/dox/qgis-2.8.2/classprocessing_1_1core_1_1parameters_1_1ParameterGeometryPredicate.html
How do I need to initialize a correct instance of the ParameterGeometryPredicate class?