I wrote a plugin for selecting and instant updating the value of the selected feature in the attribute table. I tested with a big shapefile and to select and edit 5 features takes ~5 seconds. Which isn't really fast.
Can someone look at the piece of code and give me suggestions for how I can do for faster editing?
lRect = self.canvas.mapRenderer().mapToLayerCoordinates(layer, r) layer.select(lRect, False) layer.startEditing() #for feat in layer.selectedFeatures(): for feat in layer.selectedFeaturesIterator(): feat["foo"] = my_value layer.updateFeature(feat) layer.commitChanges() layer.removeSelection()
I could use selectedFeatures() or selectedFeaturesIterator() but I tested it with both and I got nearly the same result (time).