1

Could anybody tell me what is wrong with execution of

processing.run('qgis:selectbylocation', layer2, layer, u'intersect', 0)

layer2 and layer is QgsVectorLayer object.

This is error message I got

enter image description here

  • Please remember to always provide the error message as ASCII text in the body of the question. This both makes the error legible on all devices and makes it searchable, so others might find question (and, more importantly, your answer). – Vince Nov 19 '18 at 1:09
1

You're using 2.x API, which is not compatible with 3.x. My advice is to run the command you're wanting via the gui, then check the processing history dialog which displays the equivalent python command for that operation. You can then copy this and adapt as required.

1

There is something wrong with the parameters you provide for processing.run (the error message says that it is expecting something that has an attribute called feedback, but you are providing an integer).

You should check the QGIS 3 API. See for instance: https://qgis.org/pyqgis/3.4/core/Processing/QgsProcessingAlgorithm.html#qgis.core.QgsProcessingAlgorithm.run

You will find some examples in the docs: https://docs.qgis.org/testing/en/docs/user_manual/processing/console.html

0

Thanks to ndawson I found solution. Based on processing history dialog i used command

    processing.run("native:selectbylocation",
                   {'INPUT': layer2.name(), 'PREDICATE': [0],
                    'INTERSECT': layer.name(), 'METHOD': 0})

Additionaly I had to set "Ignore invalid input features" option. Thanks a lot guys!

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.