1

I work with this perimeter\area fields:

enter image description here

i created it with "Add geometry columns" vector tool. How can i create a dynamic perimeter\ area fields, so when i create a new feature or change existed feature- those fields will be change also.

enter image description here

I try to seek the solution by create a new area field and try to find the correct expression in the field calculation, but with no success.

I can use again the "Add geometry columns" vector tool, so the attribute table will be update- but this solution is very clumsy.

0

3 Answers 3

3

There is the extension AutoFields that is made for exactly those tasks. It has some calculations already prepared. Area and perimeter are two of those. It is quite easy to handle. It will update the fields when you save your edits, not instantly in the moment you create the new feature.

In your screenshot you have the correct expression for the area calculation ($area), it should work this way. It might be due to the not fitting into the selection box, but is the field area_new selected int the drop down box, and not only _new?

3

You can add a virtual field to your table, using the fieldcalculator. When you add $area into the expression field, QGIS will automaticly calculate the area of the new and modified features

enter image description here

3

Create new field with Field Calculator and check Create virtual field when creating new field. Values from expressions (like $area) in virtual filed will be automatically updated when geometry of features changes.

This virtual field is stored only in your .qgs project until you make "non-dynamic" field (stored in data attribute table) from it. You achieve this by export (Save as..) your layer or creating new field with expression "virtual_field_name" which copy current values from virtual field.

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