[gdal-dev] OGR, GetFeatureCount after feature removal in Shape driver

Rui L. Pires rlpires at gmail.com
Thu Jun 2 05:37:41 EDT 2011


Hello everyone,

the ESRI shape driver allows feature removal for layers with update
access OGRLayer::DeleteFeature.

After successful removal of a feature and sync to disk, the method
OGRLayer::GetFeatureCount still returns the same number, as before the
deletion.

Actually, the number of records is returned, as opposed to the number
of valid features. This is confirmed when reopening the shapefile and
verifying that GetFeatureCount still returns the original number.

I realise that OGRShapeLayer::Repack may do the job of removing empty
records and thus reset the feature count. However this class is not
available in the distributed headers.

What would you propose to circumvent this issue? Is there a way to get
an accurate feature count without having to iterate through all the
valid features?

Thanks in advance.

-- 
Regards,
RLP.


More information about the gdal-dev mailing list