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.

3
  • 5
    What GIS Software are you using? Commented May 31, 2021 at 15:29
  • 2
    You also need to specify the data format in the Question, since the answer differs by format. Commented May 31, 2021 at 15:48
  • Please, do not forget about "What should I do when someone answers my question?" Commented May 25, 2023 at 7:27

1 Answer 1

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:

1
  • 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. Commented Jul 5, 2022 at 16:42

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.