7

I have a layer where I had 6 polygons. I then used the field calculator so I could get a column with the area of each of these polygons and I thought this would be applied to any other polygons I made after that, which was not the case since every new polygon appears as "NULL" in the area column. How do I make so the area is calculated automatically for all the rows?

enter image description here

0
11

You can use the AutoFields plugin, which solves exactly that issue.

Go to the plugin's docked window, select your polygon layer, choose the 'Area' field from the list of existing fields, choose the expression 'Area' and click on Save AutoFields.

enter image description here

Now QGIS will maintain your Area field up-to-date when you create new polygons or edit existing ones (you can also calculate the expression on already existing features if you like).

enter image description here

The AutoFields plugin saves the Area data into your data source file, so you can see it even if you change the QGIS project or load the data into another GIS software.

Watch this demonstration video showing how to keep other geometric properties up-to-date.

5
  • 1
    The best option to me! It avoids re-updating fields constantly after adding new features... – wiltomap Sep 20 '16 at 8:33
  • It's a great plugin. But don't we have to save the edits to see the change appearing? That is at least my experience with it. – Victor Sep 20 '16 at 9:16
  • Right Victor, when creating features you need to save edits and then the plugin does calculations. When modifying existing features the plugin does calculations right away. – Germán Carrillo Sep 20 '16 at 11:46
  • I used the plugin and it is really useful, however It seemed to slow down the software performance quite a lot when saving edits (strange since I didn't even had many features to save). I think It might be something else that happened simultaneously (mac update, something like that) because I have never had slow down issues with QGIS, so I'm going to try it later again. Thank you! – Guilherme Salles Sep 20 '16 at 21:45
  • You're welcome. Please test it again later and if you find issues please let me know by reporting them here. So far, I haven't experienced QGIS performance drawback with the plugin nor have I got any report about it. – Germán Carrillo Sep 20 '16 at 22:25
9

There are 2 approaches:

1/ select all area's which has no value ("Area" is null) and do the calculation just on the selected ones. Check 'only update XXX selected features' and 'update existing field'

enter image description here

2/ You can make a virtual field with the expression $area. Every time you add a feature the area will be calculated. Warning: a virtual field is project only. If you want to distribute the shapefile to another, you have to save it as a new one.

enter image description here

0

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.