Hello all,<div><br></div><div>I'm trying to delete a number of records from shapefile based on an attribute. The strange thing that is happening is that feature count never changes but if i make the same filter a second time the features are no longer there. The code i'm using is below. I should be doing something wrong for sure.</div>
<div><br></div><div><div><div>import os</div><div>from osgeo import ogr</div></div><div><br></div><div>path = 'C:\\datasets'</div><div>os.chdir(path)</div><div><br></div><div>shp = ogr.Open('locais.shp',1)</div>
<div><br></div><div>layer = shp.GetLayer(0)</div><div>print layer.GetFeatureCount()</div><div>layer.SetAttributeFilter('name ilike "nacional%"')</div><div><br></div><div>feat = layer.GetNextFeature()</div>
<div>while feat:</div><div>    featId = feat.GetFID()</div><div>    layer.DeleteFeature(featId)</div><div>    feat = layer.GetNextFeature()</div><div><br></div><div>shp.Destroy()</div><div><br></div><div>Any suggestions? Thanks in advance.</div>
<div>Regards,</div><div><br></div>-- <br>Hugo Martins<br><br>
</div>