[Gdal-dev] Shapefile feature deletion and feature count

Andrea Aime aaime at openplans.org
Sat Mar 10 09:33:24 EST 2007


Hi,
today I was trying to figure out an issue in my Geotools OGR
based data store and I tracked it down to a OGR strange behaviour.

I use layer.featureDelete on a shapefile, and it seems the following
happens:
* the feature does not seem to be physically removed from the shapefile,
   but is being marked as deleted instead?
* the result of layer.GetFeatureCount(1) does not change, even if the
   number of "alive" features goes down. Repeating the trick, you may
   end up with a file where feature count is x but no feature can
   be read out of it.

Is this a bug or a feature? The method documentation says:
"Returns the number of features in the layer. For dynamic databases the 
count may not be exact".

Not sure what you mean by dynamic database, re-opening the file read
only keeps on reporting the wrong number of features. That is, once
delete has been used once, the feature count is screwed up, and the
only way to really count features is to read them all?
If so, is there any way to tell an inconsistency is there, or may be
there, so that I can give up relying on the count?

Cheers
Andrea






More information about the Gdal-dev mailing list