Phil Wyatt phil at wyatt-family.com
Wed Dec 17 23:39:25 PST 2025
Make sure the field is Decimal with a precision of 3

Hi Phil,
the result of the expression

round( $area / 10000, 2) || ' ha'

is a string, thus the field type set in the Field Calculator should actually be Text, not Decimal, in order to correctly store the result of such expression.

> Christoffer Toft Hviid Jensen cth at patriotisk.dk
> Wed Dec 17 23:22:30 PST 2025> I use this expression round( $area / 10000, 2) || ' ha' in the calculator box through the attributtable.

Hi Christoffer, the function round() obviously returns 0 if the first argument is equal or less than 0.004 and the second argument is set to 2. So the expression will return '0 ha' if $area / 10000 is equal or less than 0.004 (ie $area is equal or less 40). Are you sure that $area / 10000 is greater than 0.004 (ie $area is grater than 40) for the given features?

Moreover, the unit of measure of the value returned by the function $area (which calculates the Ellipsoidal area of a geometry) is the unit of measure set in Project Properties -> General -> Measurements -> Units for area measurements. Since you are using the formula $area / 10000 in your expression, then the unit of measure of the value returned by the function $area should be square meters in order for the formula $area / 10000 to return a value in hectares.
Are you sure such settings is set to 'Square Meters'?

Regards.

Andrea


_______________________________________________
QGIS-User mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to