3

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.

Taras
  • 32,823
  • 4
  • 66
  • 137

1 Answers1

5

Let's assume there was created a feature and calculated an "area" attribute for it

input

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

settings

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.

result


References:

Taras
  • 32,823
  • 4
  • 66
  • 137
  • 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 Jul 05 '22 at 16:42