I'm trying to run processing with selectbylocation in standalone app, everything seems to run fine but the output I'm getting is the main layer always, so it's not really working. And I have no idea how to make it raise an error.

def select_by_location(main_layer, chosen_layer):

    parameters = {
        "INPUT": main_layer,
        "INTERSECT": chosen_layer,
        "METHOD": 0,
        "PREDICATE": [0],
    result = processing.runAndLoadResults("qgis:selectbylocation", parameters)['OUTPUT']
    return result
qgs = core.QgsApplication([], False)
result = select_by_location(main_layer, layer)
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'test_new')
core.QgsVectorFileWriter.writeAsVectorFormat(result, path, "UTF-8", driverName="GPKG")

1 Answer 1


Solved the issue by changing the algorithm to "Extract by location" and for feedback found:

 feedback = core.QgsProcessingFeedback()

as well as keep in mind that the location you initialize processing in your code is important.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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