[GIS] QGIS Field Calculator functions

field-calculatorfunctionqgis

Using QGIS 2.12.3, within the Field Calculator "Geometry" section, there are certain functions, such as "area", that also have a corresponding term beginning with a dollar sign, i.e. "$area". I don't understand the difference between the two.

For example, in the case of "area", the Field Calculator's description pane states: "Returns the area of a geometry polygon object", while the "$area" description is "Returns the area of the current feature." I confess that I don't understand the difference, nor how to use them in a formula.

Best Answer

$area is the area of the current feature. It's a numeric variable.

area is a function which takes a geometry, and returns its area. This geometry could be any geometry, not just the current feature.

You could say that $area is the same thing as area($geometry)

Some examples - you could use area (the function) to get the area of the bounding box of the feature, for example...

area(bounds($geometry))

.. or the area of the feature after applying buffering

area(buffer($geometry,0.01))

You could replace $geometry in those examples with a different geometry completely, for example you could lift gml or wkt from a field and use that as the geometry.

Related Question