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.

  • 5
    What GIS Software are you using?
    – Mapperz
    May 31, 2021 at 15:29
  • 2
    You also need to specify the data format in the Question, since the answer differs by format.
    – Vince
    May 31, 2021 at 15:48

1 Answer 1


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 RMC > 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 feature's geometry, it's area attribute will be updated automatically.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.