I'm wondering if anyone has any insight into the potential to auto-calculate the value of a field, either area or distance (ideally) or a formula (based on the values of say 2 other fields, or an existing field and another value).

Perhaps this is a plugin that presents a dialogue asking to what layer you want the auto-calculation to apply, and what formula or combination of fields you would like included in the calculation.

These tools are of great use to planners who are using a GIS as a drawing/design tool.


3 Answers 3


You could have your data in a PostGIS database, and then create a View containing the data from your table, along with a virtual auto-populated field.

Another option is to have triggers on the table, which inserts this field on inserts.


Here is an extended solution for the problem of automagically labelling a polygon with the area as it is created. In the labelling dialog, use the Expression Based Labelling Engine (credit to Nathan) to implement this line

"Field ID" || '\n' || toint( $area / 10000) || ' ha'

The layer has a UTM (metres) CRS and so calculates the hectares on the fly. There is a concatenation to add in


which is a line break to make the label appear on two lines, also another to add the text of ha. Field ID is the name or label for the polygon.

You can simplify the expression to calculate distance and display that. However it only displays once the feature has been completed, not whilst it is still being created which I think is the OP's interest. For me it is not much trouble to trial and error the editing of the feature to get the desired length.

(I'll have to admit I don't know any more than this, Otto showed me how to do it....)

This is for Lisboa 1.8, it will be different in trunk or older versions.


Where are the Expression-based Labeling options in QGIS?


Automatically calculating fields have been discussed on the QGIS mailing list a few months back. They are definitely on the wish list. I don't think anyone is currently working on this feature though.

For now, you can use database views to achieve something similar, as Devdatta suggested. Spatialite or PostGIS will do just fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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