I am trying to run processing algorithms in Python code editor inside QGIS. Here is my code:
zones = QgsVectorLayer('C:/Users/pamidiashoka/Downloads/OP_Pen/boundaries.shp', 'zone boundaries', 'ogr')
points = QgsVectorLayer('C:/Users/pamidiashoka/Downloads/OP_Pen/666_KAMARLE_Adharne/666_KAMARLE_Adharne.shp', 'zone boundaries', 'ogr')
extr = processing.runAndLoadResults('qgis:extractbyexpression', {'INPUT': points,
'EXPRESSION':f"filename = '2A_2_Village_Internal_Road_1'",
'OUTPUT': 'TEMPORARY_OUTPUT'})
cnt = processing.runAndLoadResults('qgis:extractbylocation', {'INPUT':zones,
'PREDICATE': 0,
'INTERSECT' : extr['OUTPUT'],
'OUTPUT': 'TEMPORARY_OUTPUT'})
The first algorithm is giving proper output and adding a new layer to the panel but the second one is throwing an error. Here is the error I am getting
Traceback (most recent call last):
File "C:\PROGRA~1\QGIS32~1.0\apps\Python39\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "<input>", line 1, in <module>
File "<string>", line 13, in <module>
File "C:\PROGRA~1/QGIS32~1.0/apps/qgis/./python/plugins\processing\tools\general.py", line 151, in runAndLoadResults
return Processing.runAlgorithm(alg, parameters=parameters, onFinish=handleAlgorithmResults, feedback=feedback,
File "C:\PROGRA~1/QGIS32~1.0/apps/qgis/./python/plugins\processing\core\Processing.py", line 187, in runAlgorithm
ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)
File "C:\PROGRA~1/QGIS32~1.0/apps/qgis/./python/plugins\processing\gui\AlgorithmExecutor.py", line 72, in execute
results, ok = alg.run(parameters, context, feedback, {}, False)
_core.QgsProcessingException: Could not create memory layer
What is the cause of this error and how can I resolve this issue?