1

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
  • From algorithm help on python console, it seems that the output name is fixed. Screenshot: ibb.co/ZT6kkvd
    – Walter
    Commented Jun 27, 2019 at 20:04

1 Answer 1

3

Seems like the temporary output layers have a fixed name. What you could do is:

  1. Run the algorithm without adding the output to the map;
  2. Change the name of the output;
  3. 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'])

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.