Thanks a lot for your suggestion Even. That is it.<div>Cheers,</div><div><br></div><div>Hugo<br><div><br><br><div class="gmail_quote">On Sun, Sep 16, 2012 at 1:40 PM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@mines-paris.org" target="_blank">even.rouault@mines-paris.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le samedi 08 septembre 2012 05:06:41, Hugo a écrit :<br>
<div class="im">> Hello all,<br>
><br>
> I'm trying to delete a number of records from shapefile based on an<br>
> attribute. The strange thing that is happening is that feature count never<br>
> changes but if i make the same filter a second time the features are no<br>
> longer there. The code i'm using is below. I should be doing something<br>
> wrong for sure.<br>
<br>
</div>I don't think you are doing something wrong. This is just a limitation of the<br>
implementation of GetFeatureCount() in the shapefile driver. When there are no<br>
attribute or spatial filter set, it returns the total number of records in the<br>
DBF file. When you delete a feature, it marks the corresponding record as<br>
invalid, but doesn't actually remove it from the file, so the total number of<br>
records remains unchanged. You can "repack" the .shp, .shx and .dbf files by<br>
running shp.ExecuteSQL("REPACK locais") (see<br>
<a href="http://gdal.org/ogr/drv_shapefile.html" target="_blank">http://gdal.org/ogr/drv_shapefile.html</a>)<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Hugo Martins<br><br>
</div></div>