How can I write an expression to update the area of polygons and lengths of features automatically as well as the sum of the areas and lengths? I am using QGIS 3.16.7 and the data format is OGR library.
- 5What GIS Software are you using?Mapperz– Mapperz ♦2021-05-31 15:29:26 +00:00Commented May 31, 2021 at 15:29
- 2You also need to specify the data format in the Question, since the answer differs by format.Vince– Vince2021-05-31 15:48:37 +00:00Commented May 31, 2021 at 15:48
- Please, do not forget about "What should I do when someone answers my question?"Taras– Taras ♦2023-05-25 07:27:51 +00:00Commented May 25, 2023 at 7:27
1 Answer
Let's assume there was created a feature and calculated an "area" attribute for it
For catching changes done to that feature i.e. automatically updating the area, please set up some defaults through Right-mouse click > Properties > Attribute Form > Fields > area > Defaults
I set $area as the 'Default value' as well as ticked the 'Apply default value on update' and clicked Apply.
So, now after modifying the feature's geometry, its area attribute will be updated automatically.
References:
- To add to this question, can I obtain an updated attribute value without modifying its geometry? By that I mean copying the style from one shp into another to duplicate the same Attributes Form properties.ale.tenorio– ale.tenorio2022-07-05 16:42:20 +00:00Commented Jul 5, 2022 at 16:42


