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],
"OUTPUT": "TEMPORARY_OUTPUT",
}
result = processing.runAndLoadResults("qgis:selectbylocation", parameters)['OUTPUT']
return result
qgs = core.QgsApplication([], False)
qgs.initQgis()
Processing.initialize()
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")
qgs.exitQgis()