<div dir="ltr">Ok, great.<div>I don't use AutoCad, seems to be a good explanation for the idx, although I have not found out whether it is</div><div>a spatial index or an .shx replacement. See <a href="https://forums.autodesk.com/t5/autocad-map-3d-forum/2018-shape-file-idx-issue/td-p/8300100">https://forums.autodesk.com/t5/autocad-map-3d-forum/2018-shape-file-idx-issue/td-p/8300100</a></div><div>discussing (sharing) problems with this .idx file in autocad.</div><div>I was at first convinced that some action on the .dbf was the cause of the problem, anyway, that does not seem</div><div>too likely anymore as the dbf rows have an id field and the rows (still) ordered ascendingly as you would expect.</div><div>Therefore the order of the shp and the dbf is likely the same.</div><div>Only the last dbf row has damage.</div><div>I am a bit unsure whether you have a valid shapefile again/still.</div><div>Unless you have a fully recovered/backed up shapefile by now, I suggest you take a (second) look at the <a href="https://www.dropbox.com/s/wj0loe0m7apuszz/test.zip?dl=0" target="_blank">link</a> I gave above.</div><div>I could repair the last weirdness (lines sticking out westward) and now it looks ok, and complete.</div><div>See <a href="https://www.dropbox.com/s/bh6pfvk2haddoqf/result.png?dl=0" target="_blank">https://www.dropbox.com/s/bh6pfvk2haddoqf/result.png?dl=0</a> for a quick glance.<br></div><div>In dark the shapefile as it was first shown in QGis, in pink the (additional) objects that have been recovered.</div><div>Best regards,</div><div>Jan</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 17, 2023 at 4:59 PM Andrea Giudiceandrea via gdal-dev <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Jan,<br>
thank you very much for looking at this issue.<br>
<br>
I had already managed to restore the .shx index file, as reported in my <br>
first message [1] [2] by fixing the GDAL/OGR SHPRestoreSHX routine [3]. <br>
Even Rouault also further improved it adding extra sanity checks, a <br>
better logic and better error messages [4].<br>
Obviously, SHPRestoreSHX routing doesn't take care of the the mismatch <br>
between the shape and dbf records number.<br>
<br>
An old but still working Shapefile recovery tool (which also handle the <br>
shp / dbf mismatch) is the "Shape Checker" [5].<br>
<br>
The .idx file may have been created by AutoCAD [6], as the user reported <br>
that he tried to open the corrupted Shapefile layer with AutoCAD after <br>
the corruption occurred.<br>
<br>
Best regards.<br>
<br>
Andrea<br>
<br>
<br>
[1] <a href="https://lists.osgeo.org/pipermail/gdal-dev/2023-May/057229.html" rel="noreferrer" target="_blank">https://lists.osgeo.org/pipermail/gdal-dev/2023-May/057229.html</a><br>
[2] <a href="https://github.com/qgis/QGIS/issues/53058#issuecomment-1547740971" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS/issues/53058#issuecomment-1547740971</a><br>
[3] <a href="https://github.com/OSGeo/gdal/pull/7774" rel="noreferrer" target="_blank">https://github.com/OSGeo/gdal/pull/7774</a><br>
[4] <a href="https://github.com/OSGeo/gdal/pull/7778" rel="noreferrer" target="_blank">https://github.com/OSGeo/gdal/pull/7778</a><br>
[5] <br>
<a href="https://web.archive.org/web/20091024035556/http://geocities.com/SiliconValley/Haven/2295/howto_shapechk.html" rel="noreferrer" target="_blank">https://web.archive.org/web/20091024035556/http://geocities.com/SiliconValley/Haven/2295/howto_shapechk.html</a><br>
[6] <br>
<a href="https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Required-files-that-make-up-a-shapefile.html" rel="noreferrer" target="_blank">https://www.autodesk.com/support/technical/article/caas/sfdcarticles/sfdcarticles/Required-files-that-make-up-a-shapefile.html</a><br>
<br>
<br>
<br>
Il 17/05/2023 12:39, Jan Heckman ha scritto:<br>
> Hi all,<br>
> <br>
> As noted in the QGis issues <<a href="https://github.com/qgis/QGIS/issues/53058" rel="noreferrer" target="_blank">https://github.com/qgis/QGIS/issues/53058</a>>, <br>
> the shx has problems that ogr2ogr (or QGis Repair Shapefile) will not fix;<br>
> The error I get in cmdline with SHAPE_RESTORE_SHX=YES is "ERROR 4: Error <br>
> parsing .shp to restore .shx".<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>