I have a shape file with only one field DN. I would like to delete all features which does not have specific value of the field. Let say the DN can be 1,2 or 3.
So far I was able to find out how to select Features and how to delete feature, but I did not succeed to combine them. Let say I want only features with DN = 3 to remain:
Selection of the Features found here, however, I do not know if it does what suppose to since I did not find the way how to check what is inside.
select = layer.getFeatures(QgsFeatureRequest().setFilterExpression(u'"DN"!=3'))delete features found here
res = Ilayer.dataProvider().deleteFeatures()As far as I know, the deleteFeatures() requires IDs of the features, but I have no idea how to get them from from select which is QgsFeatureIterator.
أكثر...
So far I was able to find out how to select Features and how to delete feature, but I did not succeed to combine them. Let say I want only features with DN = 3 to remain:
Selection of the Features found here, however, I do not know if it does what suppose to since I did not find the way how to check what is inside.
select = layer.getFeatures(QgsFeatureRequest().setFilterExpression(u'"DN"!=3'))delete features found here
res = Ilayer.dataProvider().deleteFeatures()As far as I know, the deleteFeatures() requires IDs of the features, but I have no idea how to get them from from select which is QgsFeatureIterator.
أكثر...