5

I intend to develop a model with field calculator processing using the QGIS Modeler.

How do I include the number input by the user to be as a value in Formula of Field Calculator?

enter image description here

This is the model that I want to make, but I stuck in including number parameter into my next field calculator.

For additional information, below is the interface that I want to have.

enter image description here

1
  • Did you solve the problem? If you have a solution, could you please add that? Jun 4, 2020 at 13:32

3 Answers 3

6

In Field Calculator window, you have to click enter image description here button, select "Model Input" and select "Number Parameter" (in your case, Coefficient).

enter image description here

5
4

A pretty dirty solution to this is to use the "String concatenation" tool to generate an expression that you feed into the field calculator.

3

Normally you should be able to use it as a variable @Coefficient, (originally used inputname without whitespaces and an @ at first sign) e.g. 99 * @Coefficient + 123, but in my experience this sometimes does not work using the processing tool field calculator in graphical model.

However, you can simply use refactor fields instead. It offers pretty much the same possibilities as you have with field calculator + some extra options by reorganizing fields or even adding multiple calculated fields at once. This tool will also list your available variables. Just setup your field and click on the expression button.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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