I have received a point file that was made in QGIS. if a row is deleted in QGIS it appears to be deleted, in QGIS. If I import that shp file into arcgis the attribute still shows the rows that were deleted in QGIS. If I then export the shp file in arcgis and import it to QGIS, all the rows show - it is as if nothing was deleted. Has anyone else experienced this? I am using ver2.10.1-Pisa

  • Possibly related to gis.stackexchange.com/questions/123115/…. Try @saultdon's recommendation: "You can try backing up the shapefile, then loading a new copy that's made up of only the files that end in .shp .shx .dbf .prj - delete all the other files that aren't in that list" – underdark Sep 11 '15 at 18:53

The reason for your issue is in how GDAL Shapefile driver http://www.gdal.org/drv_shapefile.html deletes features from shapefile

The OGR shapefile driver supports rewriting existing shapes in a shapefile as well as deleting shapes. Deleted shapes are marked for deletion in the .dbf file, and then ignored by OGR. To actually remove them permanently (resulting in renumbering of FIDs) invoke the SQL 'REPACK ' via the datasource ExecuteSQL() method.

This is a handy trick for improving performance: instead of removing the line from .shp, .shx, and .dbf, and rewriting all three files which can be big GDAL only updates one row in the .dbf file. When GDAL opens the data it reads the deleted line that is still physically in .shp and .shx but discards it after noticing the "deleted" flag in .dbf. Everything goes fine so far and as showed later, native ESRI code is using the same trick.

However, your description proves that ArcGIS does not care about the "deleted" flag of the .dbf file, and when it saves the shapefile again the flag is removed. As a result the deleted features are there again also for GDAL based programs.

So who makes it wrong? It is hard to say. The Shapefile specification http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf defines:

The table must contain one record per shape feature

Some may say that .dbf file which have records with deleted flags has more records. However, that is the normal way to delete records from dBase and for obvious reason. Also this old mail from 2007 http://forums.esri.com/Thread.asp?c=9&f=1193&t=218145 suggests that as least MapObjects which is and ESRI product knows to skip those "deleted by flag" records

I have looked in the javadoc and I found the method delRecord(index): "More specifically, the record is marked as deleted. While this will not actually remove the record from the file, the record will be considered to be deleted by all getRecord() methods. " or "This method DOES NOT physically remove the record from the file. "

However, despite the javadoc information it looks like at least your version of ArcGIS does not discard the deleted records.

What is safest is to "repack" the whole shapefile and remove deleted features permanently from all shp parts. In code GDAL does it with REPACK and ESRI probably with "Pack", see https://geonet.esri.com/thread/18661

Are you sure the record is not deleted? Remember that deleting a record in dbase file usually only marks the record for deletion and does not actually delete it. To do that you must do an:


after the update

A workaround for you is to save your QGIS shapefile into a new shapefile either with QGIS or with the GDAL utility ogr2ogr http://www.gdal.org/ogr2ogr.html.

Further reading in comments of this QGIS ticket https://hub.qgis.org/issues/11007

  • Thanks for your insight! Saving it to a new shapefile does the trick. – Steve Sep 14 '15 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.