I am developing a plugin for QGIS and have hit a snag that does not seem to have happened before.
After having created a point memory layer with attributes, I need to delete features. The following code was used to delete same, however, after this operation, all features disappear from the mapcanvas. The features are displayed in the browser, with the exception of the deleted ones, and the layer is still shown as an existing layer in the layer legend.
Here's snippets of the code:
more code that adds point features successfully...
def createTmpLyr(self): uri = "Point?crs=epsg:4248&field=id:integer&field=Pt:string(20)&index=yes" self.vl = QgsVectorLayer(uri, "temporary_points", "memory") QgsMapLayerRegistry.instance().addMapLayer(self.vl)
Code that generates a selection of points to be deleted
self.vl.setSelectedFeatures(listOfPts) ntBndPts=self.vl.selectedFeatures() self.delNtBndPts(ntBndPts) self.vl.commitChanges() def delNtBndPts(self, pts): print pts with edit(self.vl): for feature in pts: self.vl.deleteFeatures([feature.id()])