Introduction
The shapefile is the vector map format of Esri, the maker of ArcGIS, introduced with ArcView in the early 1990s. Esri published its specification in 1998, and it became the most common way to exchange points, lines and polygons between GIS programs. It is still everywhere, despite limits such as 2 GB per file and ten-character field names.
A shapefile is not one file but several with the same name:
.shp: the shapes, their geometry.shx: an index giving the position of each shape in the.shp.dbf: the attributes, one row per shape, in dBASE format.prj(optional): the coordinate system, as well-known text
All of them are needed, so shapefiles are usually shared as a ZIP archive.
Structure
The .shp file starts with a 100-byte header. Some of its numbers are
big-endian and some little-endian:
| Offset | Size | Holds |
|---|---|---|
0 | 4 | file code 9994 (00 00 27 0A), big-endian |
24 | 4 | file length in 16-bit words, big-endian |
28 | 4 | version 1000, little-endian |
32 | 4 | shape type, little-endian: 1 point, 3 polyline, 5 polygon, 8 multipoint, and Z and M forms |
36 | 64 | bounding box: minimum and maximum X, Y, Z and M as 64-bit floats |
Records follow. Each has an 8-byte header, the record number and content length,
big-endian, then the content, little-endian: the shape type, then the shape’s bounding
box, parts and points. The .shx file has the same 100-byte header, then
8 bytes per record giving its offset and length.
0Header file code, length, version, shape type, bounding box100 bytes100Records record number, length, then the shaperepeated
Links
Software
- QGIS (Windows, macOS, Linux)
- ArcGIS Pro (Windows)
- GDAL and its
ogr2ogrconverter (Windows, macOS, Linux) - Mapshaper, which simplifies and converts shapefiles in a web browser
Developers
Reference
- ESRI Shapefile Technical Description, Esri, 1998