0

I need a Field Calculator script to select a feature (trees layer), if values from multiple fields, namely the amount of pine, spruce and birch, meet a specific condition: The values of pine "V101__m_3_", spruce "V201__m_3_" and birch "V302__m_3_" columns have to be at least 20% of the total wood volume column "Vtot__m_3_". The "Vxxx__x__x" is the name of the fields.

The values are integers.

How is this done?

I've tried this, but it doesn't work:

"V101__m_3_"+ "V201__m_3_"+ "V301__m_3_"+ "V302__m_3_" > 20/ "Vtot__m_3_"
2
  • 2
    Could you please edit your question, and add a sample of your data?
    – Berend
    Oct 19, 2021 at 10:42
  • 1
    It's hard to answer without seeing the actual data, but I notice that you are summing 4 values, rather that 3 (pine, spruce and birch). 20% (i.e. one fifth) of the total value would be "Vtot__m_3_" / 5 instead of 20 / "Vtot__m_3_"
    – Berend
    Oct 19, 2021 at 11:00

2 Answers 2

1

Assuming that you want the sum of the four columns to be greater than 20% (or 1/5) of the fifth, you could also say that 5 times the sum of the 4 columns should be greater than the fifth. The expression would be:

("V101__m_3_"+ "V201__m_3_"+ "V301__m_3_"+ "V302__m_3_") * 5 > "Vtot__m_3_"
0

It's actually very hard to answer the question by speculating how your data tree looks like. But I assume that you have three fields for pine, spruce, and birch; each has int values as a percentage.

So you could use:

("field_1" / "field_total" *100) >= 20 and ("field_2" / "field_total" *100) >= 20 and ("field_3" / "field_total" *100) >= 20

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.