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

Jan Heckman jan.heckman at gmail.com
Tue May 16 04:52:00 PDT 2023


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.
Also, to be sure, the expected number of rows is relevant so as not to call
victory too soon.
Jan

On Tue, May 16, 2023 at 1:41 PM Andrea Giudiceandrea via gdal-dev <
gdal-dev at lists.osgeo.org> wrote:

> Il 15/05/2023 15:34, Andrea Giudiceandrea ha scritto:
> > it seems to me ogr fails to properly create the .idx [EDIT: .shx] file:
> > it incorrectly stores, in the index file header, the total length in
> > 16-bit words of the .shp file instead of the total length in 16-bit
> > words of the .idx [EDIT: .shx] file itself.
>
> Looking at the code, SHPRestoreSHX initially copies the SHP header
> (including the SHP content length) to the SHX file and then it doesn't
> updates the SHX content length in the SHX header when an error occurred
> during the reading of the SHP file.
>
> I propose the PR https://github.com/OSGeo/gdal/pull/7774 in order to
> update the SHX content length even if an error occurred.
>
> Maybe would it be better to let SHPRestoreSHX modify the SHX file (when
> already present) only at the end of the SHP reading procedure and only
> if no error occurred?
>
> Best regards.
>
> Andrea Giudiceandrea
> _______________________________________________
> 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/20230516/d8d577f8/attachment.htm>


More information about the gdal-dev mailing list