3

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

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Dec 25, 2015 at 10:58
1
  • 1
    Is the layer name hard-coded into your model or is it one of the inputs of the model? Commented Dec 25, 2015 at 21:52

1 Answer 1

2

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
##Layer=vector
##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

answered Feb 5, 2016 at 14:56

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.