2

I'm trying to create a tool with graphical modeler of QGIS where I add a new attribute which represents length of the line divided by an certain number of interval informed in his attribute table. enter image description here

For that I use Field calculator algorithm where I write the expression (In pre-calculated value):

$length  / @AttributDivisionnumber

I tried to use:

$length / attribute(@AttributDivisionnumber) 

enter image description here enter image description here

But I have always the same error message No node roots. enter image description here I understand than Qgis consider than @AttributDivisionnumber is not a number when I use graphical modeler ... but idk how change it. Someone have any idea?

1
  • What does the error translate to in english?
    – Bera
    Commented Mar 14, 2023 at 18:30

1 Answer 1

1

You need to use eval() because the variable returns only the name of the field as a string, not the value(s) of this field:

$length / eval(@AttributDivisionnumber)

eval() Evaluates an expression which is passed in a string. Useful to expand dynamic parameters passed as context variables or fields.

1
  • Unfortunately It doesn't work, it keeps putting me 'No root node' ... Commented Mar 15, 2023 at 20:49

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.