Shapefile

Also known as: Esri shapefile

On this page 7

A shapefile is a geospatial vector data format that stores the geometry of points, lines or polygons together with descriptive attributes in a set of companion files that share one base name. Published by Esri in the early 1990s as an open technical description, the Esri shapefile became the most widely exchanged GIS format and remains one of the reference data formats in the Data field, even though its design reflects the constraints of desktop computing three decades ago.

Among data formats, the shapefile occupies a specific niche: it is not a single file, it holds one geometry type per dataset, and it relies on the old dBASE table format for attributes. Understanding these properties explains both its universal support and the frustrations that push modern pipelines toward GeoJSON, GeoPackage or GeoParquet.

How a shapefile is assembled from companion files

A shapefile is a multi-file dataset in which each file carries one aspect of the data, and the files are linked only by a shared base name and record order. The geometry lives in the .shp file, a binary index of record offsets lives in the .shx file, and the attribute table lives in the .dbf file. The nth geometry matches the nth attribute row, so the three files must always travel and change together.

The following table lists the mandatory and the most common optional components and what each one contributes.

ExtensionRequiredContent
.shpYesGeometry records in binary form
.shxYesFixed-length index of record offsets
.dbfYesAttribute table in dBASE format
.prjNo, but essentialCoordinate reference system as WKT text
.cpgNoCharacter encoding of the .dbf file
.sbn / .sbxNoEsri spatial index
.qixNoQuadtree spatial index used by open-source tools
Components of a shapefile dataset

Inside the .shp file, a 100-byte header records the file length, the shape type code and the bounding box of all features. Each record then stores its own bounding box, the number of parts and points, and the coordinates as 64-bit floating-point numbers. Polygon rings follow an orientation rule: outer rings run clockwise and holes run counterclockwise, which is the opposite of the convention required by the GeoJSON specification.

Geometry types and attribute rules

Every shapefile declares exactly one shape type in its header, so a dataset cannot mix points and polygons. Variants with Z values store elevation, and variants with M values store a linear measure such as distance along a road, which linear referencing systems use for mileposts.

Shape typeCodeTypical use
Point1Wells, addresses, sensor locations
Polyline3Roads, rivers, pipelines
Polygon5Parcels, administrative boundaries, land cover
MultiPoint8Clusters of survey points
PolygonZ15Building footprints with elevation
PolyLineM23Routes with measured distances
Main shape types

The attribute side inherits the limits of dBASE. Field names are restricted to 10 characters, text fields hold at most 254 characters, and there is no true null value for numeric fields in many implementations. Date fields store only dates, not times, and there is no native type for booleans with a defined null state, long text or nested values.

Size limits and technical constraints

The shapefile format uses 32-bit offsets, which caps each .shp and .dbf component at about 2 GB. Large national datasets, such as building footprints for an entire country, must therefore be split into tiles or delivered in another format.

  • No topology: shared boundaries between neighboring polygons are stored twice, so edits can create gaps and slivers.
  • Encoding ambiguity: without a .cpg file, readers may guess the wrong character set and corrupt accented names.
  • Missing projection: a dataset delivered without the .prj file places features at the wrong location or rejects reprojection.
  • Fragile transfer: email filters and careless copying often separate the companion files, which breaks the dataset.

These constraints are not bugs in individual tools; they are properties of the specification itself, which Esri has not extended in decades. Software can work around them, but any workaround reduces interoperability, which is the main reason to choose a shapefile in the first place.

Shapefile compared with other geospatial formats

The shapefile competes with text-based, database-based and columnar geospatial formats, and each one fixes a different weakness. The table compares the formats that most often replace it.

FormatStructureMain strengthMain weakness
ShapefileSeveral binary filesUniversal tool support2 GB cap, 10-character field names
GeoJSONSingle text fileReadable, ideal for web APIsLarge and slow for big datasets
GeoPackageSingle SQLite databaseMultiple layers, no practical size capLess common in older workflows
GeoParquetColumnar binary fileFast analytics at scaleLimited support in legacy desktop GIS
Shapefile and common alternatives

For analytical pipelines, GeoParquet stores geometry as well-known binary in a column next to the attributes, so engines can read only the columns they need. For editing and archiving, GeoPackage, an Open Geospatial Consortium standard, removes the file-set problem entirely. The shapefile still wins when the recipient’s software is unknown.

When to use or replace a shapefile

The practical rule is to accept shapefiles as input and to produce them only on request. The decision table summarizes common situations.

SituationRecommended formatReason
Delivery to an agency that requires itShapefileContract or regulation demands it
Exchange with unknown desktop GIS usersShapefile or GeoPackageBoth open almost everywhere
Dataset larger than 2 GBGeoPackage or GeoParquetNo 32-bit offset limit
Web map or REST APIGeoJSONNative to browsers and JavaScript
Cloud analytics in a data lakeGeoParquetColumnar reads and compression
Choosing a format for vector data

When a shapefile must be produced, always include the .prj and .cpg files, keep field names short and meaningful, and distribute the set as one ZIP archive so that the components stay together. Most modern libraries, including GDAL and the Python geospatial stack, can read a zipped shapefile directly.

A plain-language summary

A shapefile is a common way to save map data, such as the outline of a lake or the location of every bus stop in a city. Instead of one file, it is a small bundle of files that belong together. Think of a book whose pages and index are printed separately.

One file holds the shapes. Another helps find them quickly. A third holds facts about each shape, such as a name or a population. If one piece goes missing, the map breaks. That is why people usually send shapefiles as a single ZIP archive.

An example from practice

A regional water utility needs to send its network of 14,000 pipe segments to an engineering consultancy that will model flood risk. The consultancy uses older desktop GIS software, so the utility’s analyst exports the pipe layer as a polyline shapefile. Several attribute names, such as installation_year and material_class, exceed the 10-character limit and are truncated automatically, so the analyst renames them to INST_YEAR and MATERIAL before export.

The analyst checks that the .prj file records the national projected coordinate system and adds a .cpg file declaring UTF-8, because street names contain accented letters. The five files go out in one ZIP archive of about 18 MB. The consultancy opens the data on the first attempt, with pipes aligned correctly to its base maps, and returns flood results as a GeoPackage, which the utility loads without any conversion work.