ASRodrigo
ASRodrigo

Reputation: 331

What is the proper way to repair/recreate the .shx of an ESRI Shapefile using gdal?

I can recreate the missing .shx file by using the gdal command ogr2ogr and specifing the config "--config SHAPE_RESTORE_SHX YES".
But, although it recreates the .shx file it gives me an error: -nln name must be specified combined with a single source layer name, or a -sql statement, and name must be different from an existing layer.

I mean, seems like i'm not using the ogr2ogr command properly. So, how can i recreate it in the correct manner?

Full command

ogr2ogr -f "ESRI Shapefile" -overwrite -skipfailures --config SHAPE_RESTORE_SHX YES file.shp file.shp

Upvotes: 0

Views: 112

Answers (2)

user2856
user2856

Reputation: 1205

Use ogrinfo instead. Then you don't need to create a new output if you only want to restore the .shx file.

ogrinfo --config SHAPE_RESTORE_SHX YES file.shp

Upvotes: 0

Pieter
Pieter

Reputation: 1516

I think the output file name should be different than your input file name.

Upvotes: 0

Related Questions