If I have a geoalgorithm in my model and I want the value from one the parameters, then how can I get it? For example I want the layer name in the parameter layer in below figure so I get the value Pts1.

enter image description here

  • 1
    Is the layer name hard-coded into your model or is it one of the inputs of the model? – underdark Dec 25 '15 at 21:52

Don't think you could do this directly through the modeler but you could create a custom script which, when run can simulate a model, allows you to fetch the name of the layer and use it for processing.

The following script uses the Field Calculator tool which creates a new field with the layer name and populates the values with the layer name (the python command is layer.name()):

##Fetch layer name=name
##Result=output vector

layer = processing.getObject(Layer)  
processing.runalg("qgis:fieldcalculator", Layer, layer.name(), 2, 99, 0, True, "'" + layer.name() + "'", Result)

Script interface

Results of script

You can have a look at the documentation on how to create scripts and call various functions and their associated parameters:

Using processing algorithms from the console

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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