It appears as though the function editor on the Field Calculator is not recognizing the
Geometry() method on the feature.
Example code below, always returns -1 into the field I populate from the Field Calculator. The features have valid geometry. The source table is standalone and not a join.
When I also do a
print(geometry()) call, it returns
The weird thing is that on the Field Calculator preview, it shows the correct value.
The issue is similar to this issue:
However the tables I am working with have no joins. I have tested on both 3.18 and 3.22 versions with a blank project. No joins/relationships.
from qgis.utils import qgsfunction from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def test_geom(feature, parent): area_calc = feature.geometry().area() return area_calc