ESRI Shapefile

What is an ESRI Shapefile?

The ESRI Shapefile is one of the most widely used geospatial vector data formats for Geographic Information Systems (GIS). Developed by Esri in the early 1990s, shapefiles store the geometric location and attribute information of geographic features such as points, lines, and polygons.

Despite its name, a "shapefile" is actually a collection of multiple files that work together to describe vector features. This format has become an industry standard due to its simplicity, widespread software support, and ability to handle large datasets efficiently.

Shapefile Viewer

Upload a .zip file containing shapefile components (.shp, .shx, .dbf, .prj)

1
Upload Shapefile ZIP
πŸ—ΊοΈ
Drop shapefile ZIP here
or click to browse (.zip file containing .shp, .shx, .dbf, .prj)

File Structure and Components

A shapefile is actually a collection of files that work together. The three mandatory files are:

1. Main File (.shp)

The .shp file contains the geometry data in binary format. It stores the actual shape coordinates (points, lines, or polygons) using a specific binary structure defined by Esri.

.shp File Binary Structure:

File Header (100 bytes):
  - File code (9994)
  - File length
  - Version (1000)
  - Shape type (Point=1, Polyline=3, Polygon=5, etc.)
  - Bounding box (minX, minY, maxX, maxY)

Records:
  - Record header (record number, content length)
  - Shape type
  - Geometry data (coordinates)

2. Index File (.shx)

The .shx file is a positional index that stores the byte offset of each record in the .shp file. This allows software to quickly jump to specific features without reading the entire file sequentially.

3. dBASE Table (.dbf)

The .dbf file stores attribute data in dBASE IV format. Each row corresponds to a feature in the .shp file, and columns contain attribute fields like names, IDs, categories, and measurements.

.dbf File Structure:

Header (32 bytes):
  - Version number
  - Last update date
  - Number of records
  - Header length
  - Record length

Field Descriptors (32 bytes each):
  - Field name (11 bytes)
  - Field type (C=Character, N=Numeric, D=Date, L=Logical)
  - Field length
  - Decimal count

Records:
  - Deletion flag
  - Field values

4. Projection File (.prj) - Strongly Recommended

The .prj file contains the coordinate reference system (CRS) definition in Well-Known Text (WKT) format. Without this file, the coordinates are ambiguous and cannot be properly interpreted.

Optional Files

Geometry Types

Shapefiles support various geometry types, each representing different spatial features:

Supported Geometry Types:

Type 1:  Point               Single coordinate (X, Y)
Type 3:  Polyline            Connected line segments
Type 5:  Polygon             Closed area with boundary
Type 8:  MultiPoint          Multiple disconnected points
Type 11: PointZ              Point with Z (elevation)
Type 13: PolylineZ           Polyline with Z values
Type 15: PolygonZ            Polygon with Z values
Type 21: PointM              Point with M (measurement)
Type 23: PolylineM           Polyline with M values
Type 25: PolygonM            Polygon with M values
Type 31: MultiPatch          3D surface (TIN, mesh)
Important: Each shapefile can only contain ONE geometry type. You cannot mix points and polygons in the same .shp file.

Applications and Use Cases

Shapefiles are used across numerous industries and applications:

Advantages and Limitations

Advantages

Limitations

Modern Alternatives

While shapefiles remain popular, modern alternatives address many limitations:

GeoPackage (.gpkg)

GeoJSON

FlatGeobuf (.fgb)

Working with Shapefiles

Desktop GIS Software

Programming Libraries

Best Practices