1

I want to see the contents of an .shx file to see how the index information is stored in these files so that I can get some help in writing my own shapefiles.

How can I open and use the .shx files?

  • Search old arcview forum. There were a library in vb dealing with this – FelixIP Aug 31 '14 at 9:51
  • 1
    shapelib.maptools.org – FelixIP Aug 31 '14 at 10:00
  • The SHX component is not really an "index" -- more like an indirect access offset list. – Vince Aug 31 '14 at 17:40
6

The .shx file is binary, so you need a hex editor to look inside.

The format is described in http://en.wikipedia.org/wiki/Shapefile:

The shapefile index contains the same 100-byte header as the .shp file, followed by any number of 8-byte fixed-length records which consist of the following two fields:
Bytes   Type    Endianness  Usage
0–3     int32   big     Record offset (in 16-bit words)
4–7     int32   big     Record length (in 16-bit words)

Using this index, it is possible to seek backwards in the shapefile by, first, seeking backwards in the shape index (which is possible because it uses fixed-length records), then reading the record offset, and using that offset to seek to the correct position in the .shp file. It is also possible to seek forwards an arbitrary number of records using the same method.

You will find further links at the bottom of the wiki page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.