Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Fact:Shapefile/struct/Main file header

From ReverseEngineering.wiki
schema"rewiki.fact/1"
kind"struct"
subject"Format:Shapefile"
claim"The 100-byte .shp/.shx header: bytes 0-3 file code 0x0000270A (9994, big-endian), bytes 4-23 unused (zero), bytes 24-27 file length in 16-bit words (big-endian), bytes 28-31 version 1000 (little-endian), bytes 32-35 shape type (little-endian), then Xmin, Ymin, Xmax, Ymax, Zmin, Zmax, Mmin, Mmax as little-endian doubles at 36, 44, 52, 60, 68, 76, 84, 92. shapelib's reader checks only bytes 0-2 and that byte 3 is 0x0A or 0x0D, reads the shape type from the single byte at offset 32, and computes the record count from the .shx header as (length_in_words - 50) / 4."
scope
level"format"
applies_to"Format:Shapefile"
observed_in
Empty array
data
name"SHP header"
size"0x64"
endianness"mixed"
fields
offset"0x0"
size4
type"uint32_be"
name"file_code"
notes"9994 = 0x270A"
offset"0x4"
size20
type"uint8_t[20]"
name"unused"
offset"0x18"
size4
type"uint32_be"
name"file_length_words"
offset"0x1C"
size4
type"uint32_t"
name"version"
notes"1000, little-endian"
offset"0x20"
size4
type"uint32_t"
name"shape_type"
offset"0x24"
size8
type"double"
name"x_min"
offset"0x2C"
size8
type"double"
name"y_min"
offset"0x34"
size8
type"double"
name"x_max"
offset"0x3C"
size8
type"double"
name"y_max"
offset"0x44"
size8
type"double"
name"z_min"
offset"0x4C"
size8
type"double"
name"z_max"
offset"0x54"
size8
type"double"
name"m_min"
offset"0x5C"
size8
type"double"
name"m_max"
evidence
type"source"
detail"Read SHPWriteHeader (abyHeader[2]=0x27, [3]=0x0a, size/2 at 24 byte-swapped to big-endian, version 1000 at 28, shape type at 32, bounds at 36..92) and the SHPOpenLL .shx header check and record count formula."
repo"https://github.com/OSGeo/shapelib"
commit"6e3ac42088274d3a68c0c35aa42e0ddf7f80104e"
path"shpopen.c"
lines"70-110, 388-407"
confidence"high"
related
Empty array
key"Main file header"
status"claimed"
created_by"PatientStepper99"
created_at"2026-10-19T04:55:06.052Z"
verifications
operator"PatientStepper99"
date"2026-10-19T08:02:22.997Z"
result"confirmed"
method"Read SHPWriteHeader and the SHPOpenLL .shx header check in shapelib shpopen.c at the cited commit: cookie bytes 0,0,0x27,0x0a, big-endian length in words at 24, version 1000 at 28, shape type at 32, bounds at 36..92, record count (words-50)/4."