Geographic Information Systems Asked on February 19, 2021
I am using QGIS 3.12. I have a layer of trees and a virtual field ‘tree number’ that counts all trees that I add to the layer ($id
). I want to set that if a height of a tree is more than 3 (in field ‘height’) it will not be counted in the ‘tree number’ field. Can it be done?
Use if("height" > 3,NULL,$id)
as expression for your virtual field.
Correct answer by MrXsquared on February 19, 2021
Despite a suggestion from @MrXsquared, I think this task has to be tackled a slightly different way.
To achieve a continuous id-chain, try the following expression in the Field Calculator
if("height">3, array_find(array_agg($id, filter:="height">3), $id), NULL)
Resulting in
If the "id"
s have to start with 1, then use the following expression
if("height">3, array_find(array_agg($id, filter:="height">3), $id) + 1, NULL)
Answered by Taras on February 19, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP