blankblank blank

Fixing Corrupt Shapefiles

I’ve posted before on two free Windows apps for fixing corrupt shapefiles, Shape Checker and Shapefile Repair Tool. PerryGeo describes a third option: use the command-line tool ogr2ogr to re-write the shapefile under a new name, hopefully with the corrupt parts fixed. From that post, and from its comments, you would use the following command operation:

ogr2ogr -f “ESRI Shapefile” –skipfailures shiny_new_clean_dataset.shp corrupted_dataset.shp corrupted_dataset

ogr2ogr is available as part of the installable FWTools package, but can also be installed using the OSGeo4W program covered earlier covered earlier on this blog.

Don’t like command-line operations? The free ogr2ogr GUI ogr2gui can do the same operation, with a little extra effort:

1. Select the corrupt shapefile as the source, and set the Target type as “Shapefile”:

3-31-2009-7.32.19 PM

2. Add in the “-skipfailures” switch by typing in the line command box below:

3-31-2009-7.35.20 PM

3. Click “Execute”, and you’re done. Unfortunately, I didn’t have a corrupt shapefile to test it on, but worked fine on a good shapefile. If you’ve got a corrupt shapefile, let me know if it worked for you.

Keep in mind that this isn’t a guaranteed fix. PerryGeo’s post quotes a 90% success rate, and the comments to the post note that sometimes in a corrupt shapefile, the fixed file may not have the attributes correctly linked to the matching shapes. YMMV.

Looking for something else? Enter some keywords below, then click "Search".    

2 Responses to “Fixing Corrupt Shapefiles”

  1. 1 Tomas IV.

    I would add, that the ogr2ogr command (or any other format translation tool) can be useful also if you have issues with text encoding of shapefile attribute data stored in .dbf file acompanying the .shp.
    Quite common problem for us in countries using extended character sets. Many free tools to translate encodings could not properly handle .dbf files or lack support for needed encodings.
    It is possible to get around this by converting the shapefile (to .gml for example), translate encoding of this file and then convert it back to shapefile.

  2. 2 Mnweni

    In AV 3.2 opening a shp file that was not closed on exit gave an error ‘Incorrect shape type’. The Fix worked perfectly, with no apparent damamge to the features or the attribute data

Comments are currently closed; feel free to contact me with questions/issues.