When running processing's 'Extract selected features' with the option of 'Create temporary layer' (in memory), the resulting layer is always called 'Selected features'. Can this name be customized from the script? The documentation doesn't provide an answer.
1 Answer
Seems like the temporary output layers have a fixed name. What you could do is:
- Run the algorithm without adding the output to the map;
- Change the name of the output;
- Load the output with the new name.
So you could use something like the following:
result = processing.run("native:extractbylocation",
{'INPUT':'path/to/input.shp','PREDICATE':[0],
'INTERSECT':'path/to/intersect_layer.shp',
'OUTPUT':'TEMPORARY_OUTPUT'})
result['OUTPUT'].setName('newName')
QgsProject.instance().addMapLayer(result['OUTPUT'])