I wrote the following code in order to automatically extract the objects' length of a line layer, but I think the « measureLine » expression is not working. This expression works very well PyQgis 2.0. Is there a new expression in PyQgis 3.0 ?
def dist_seg(layer):
L=[]
features=layer.getFeatures()
d = QgsDistanceArea()
for i, element in enumerate(features):
m = d.measureLength(element.geometry())
L.append((i, round(m,1)))
return L