3

I am actually trying to create a new field in a table with the Model Builder (Field calculator function).

Is there a command that creates a new field, so I can do calculations directly in that new field?

I know that there is a function, which creates a new field when using the field calculator directly but I need a command for it.

In Detail: I want to calculate the percent of an area with this command ($area / sum(area))*100 by using the Modeler, but I want it to be written in an existing layer, creating a new field for it.

5
  • Sorry, your question is unclear. When you apply the fieldcalculator, by default every time you run the tool, a new field is created (you must check the box next to Update existing field to avoid that). Insert your expression, give a name to the new field and run the field calculator - you're done. So your question does not make sense to me: can you add more details about what the problem is?
    – Babel
    Commented Aug 16, 2021 at 14:44
  • if u use the field caluclator with the Modellbuilder, you havent got the option "Update existing field" or " Add a new field" or something. You just have a command line. So I need a command to create that new field in the existing layer.
    – lesto
    Commented Aug 16, 2021 at 14:49
  • To be clear, i am not using the field calculator by itself, i am using it in the Modellbuilder. Try it ;), you will see.
    – lesto
    Commented Aug 16, 2021 at 14:52
  • It does work, even with Modelbuilder, see screenshot: i.sstatic.net/iCboM.png where you see where I introduced the name of the field that will be created. I'm not sure if we speak about the same thing? Can you add additional information or a screenshot?
    – Babel
    Commented Aug 16, 2021 at 15:05
  • In your input-layer you need to have a field named area for your expression to work, by the way.
    – Babel
    Commented Aug 16, 2021 at 15:06

1 Answer 1

2

I found out what I did wrong. I forgot to set up the Output (Green mark) and only set up the input because I thought the Model Builder will create a second layer, what I didn't want it to, because it shall be written in the same layer (Red mark), if I would do it the way in the picture. I deleted the Red mark now and directly putted it from "Add geometry" to the "Field calculator" and set up the one output layer.

enter image description here

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.