[gdal-dev] Shapefile with corrupted index: SHAPE_RESTORE_SHX=YES doesn't correctly repairs it.

Jan Heckman jan.heckman at gmail.com
Wed May 17 03:53:47 PDT 2023


Have to get back on this, I did not look well at the shapefile I generated
(see last mail).
It is both better and worse. It has most of the missing objects, to my
surprise, but appears to have some invalid coordinates
which show up as horizontal lines in the west part. Still it may help in
reconstruction, I think.
Good luck,
Jan

On Wed, May 17, 2023 at 12:39 PM Jan Heckman <jan.heckman at gmail.com> wrote:

> Hi all,
>
> As noted in the QGis issues <https://github.com/qgis/QGIS/issues/53058>,
> the shx has problems that ogr2ogr (or QGis Repair Shapefile) will not fix;
> The error I get in cmdline with SHAPE_RESTORE_SHX=YES is "ERROR 4: Error
> parsing .shp to restore .shx".
> Long time ago I wrote my own version to recreate the .shx from the .shp,
> and it does restore the .shx (leaving me to wonder whether my routine is
> really correct);
> long story short, the repaired shapefile loads fine, but the shp does not
> contain the missing geometries anyway,
> and the dbf doesn't have rows of missing objects (as shown in the QGis
> issue).
>
> The missing objects are presumed lost, see issue.
>
> Looking at the .idx file I surmise that it is a foxbase/foxpro index. Good
> (very) old dbase has .mdx and .ndx.
> DBF index files are not part of the shapefile spec.
> The layout of the file does not fully fit the few descriptions I have, but
> looks like btree record blocks with keys
> that may address column H (soil erosion).
> The presence of this 'foreign' (in the context of shapefiles) file made be
> think that perhaps the .dbf has been
> modified using foxpro/foxbase, leading to an error when saving again in
> QGis.
> Another bit of evidence for such a scenario is that the last row in the
> .dbf is garbled.
> (check with LibreOffice Calc).
>
> FWIW a link <https://www.dropbox.com/s/wj0loe0m7apuszz/test.zip?dl=0> to
> the worked shapefile.
>
> On Tue, May 16, 2023 at 2:03 PM Andrea Giudiceandrea via gdal-dev <
> gdal-dev at lists.osgeo.org> wrote:
>
>> Il 16/05/2023 13:52, Jan Heckman ha scritto:
>> > Also out of curiosity,
>> > Are you willing to share the shapefile, preferably at least shp and
>> dbf,
>> > but probably .shp alone will do and .prj helps for checking conversion
>> > results.
>>
>> Hi Jan,
>> the corrupted Shapefile layer is available in the QGIS issue report at
>> https://github.com/qgis/QGIS/issues/53058
>>
>> Best regards.
>>
>> Andrea
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20230517/f18304af/attachment-0001.htm>


More information about the gdal-dev mailing list