Calculating the length of a geometry line object using the Field Calculator gives you 2 options:
$lengthwhere the length calculated by this function respects both the current project's ellipsoid setting and distance unit settings
lengththat performs planimetric calculations in the Spatial Reference System (SRS) of this geometry, and the units of the returned length will match the units for the SRS.
Both these functions result different numbers.
That I am trying to do is to make a plugin using python that performs these 2 different functions.
With the following code I can access to geometry length of my selected features and thus the
$length in my case:
layer = qgis.utils.iface.activeLayer() features = layer.selectedFeatures() for f in features: geom = f.geometry() print ("Length:", geom.length())
How I can access to length as well?