Tom Jeffery wrote:
Chaitanya,

I wrote up a method to find and delete geometries that fall outside of the
reported Extent from the shapefile.  It seems to be doing the trick, though
with some strange side effects.
It finds the bad features properly, and I remove them with
layer.DeleteFeature(feature.GetFID()), but the .shp part of the shapefile is
never updated.  (The dbf is the only file to change.)  Everything looks fine
in OGR and ArcGIS, but if I run repair geometry in ArcGIS on the same file,
it deletes the "same" records, causing the file to become completely
unreadable.

I seem to recall reading about this before, but haven't turned up anything
in google searches.  Is there a method to properly delete a record so the
.shp is updated as well?

Tom,

I believe OGR takes the approach of marking shapes deleted by setting the
deleted flag in the .dbf file.  As far as I knew, this is a reasonable
approach as far as ArcGIS is concerned.  I don't know why ArcGIS does
something that corrupts the file.  If you figure out the issue let us know.

In the meantime, after doing the cleanup operation you can run ogr2ogr on
the file to create a new file with all deleted records/shapes discarded.

eg.
ogr2ogr out.shp in.shp

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, [email protected]
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent

_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to