Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 shape files.

Can any one guide me on how can I open and use the .shx files?

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

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
Thank You Andre I found the link on shape dump at webprocessresults.com/pgsActv/ShpDump.aspx to be very useful. –  dipz Aug 31 at 16:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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