In a QGIS 2.0 plugin for windows, I calculate length and update a field with the values. It works, but takes a lot of time. Execution for this part only takes about ten minutes. Can anyone suggest anything to speed things up?
def calculatelength(self):
idx = self.resLayer.fieldNameIndex('Longueur')
caps = self.resLayer.dataProvider().capabilities()
features = self.resLayer.getFeatures()
for feature in features:
if caps & QgsVectorDataProvider.ChangeAttributeValues:
fid = feature.id()
flen = feature.geometry().length()
attrs = {idx : flen}
self.resLayer.dataProvider().changeAttributeValues({fid : attrs})