# Shapefile

Shapefile 是由 Esri（原环境系统研究所，ESRI）开发的一种矢量地理空间数据格式，用于存储数据集中空间要素的非拓扑几何与属性信息。尽管名称是单数，一个 shapefile 并非单个文件，而是一组共享同一前缀的文件簇：存放要素几何的主文件（.shp）、索引文件（.shx），以及存放属性的 dBASE 表（.dbf）。Esri 于 20 世纪 90 年代推出该格式后，它迅速成为 GIS 数据交换事实上的标准，至今仍被广泛部署，尽管其种种局限已促使许多用户转向 [GeoPackage](https://www.edgepedia.org/zh/geopackage) 等地理空间数据库格式。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup><sup> • </sup><sup>[2](https://loc.gov/preservation/digital/formats/fdd/fdd000280.shtml)</sup>

| 关键事实 | 详情 |
|---|---|
| 必需文件 | .shp（几何）、.shx（记录偏移索引）、.dbf（属性）；三者共享同一 8.3 命名约定文件前缀<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup> |
| 几何模型 | 以矢量坐标存储的非拓扑几何；支持点、线、面要素，每个文件只能有一种形状类型<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup><sup> • </sup><sup>[3](https://gdal.org/en/stable/drivers/vector/shapefile.html)</sup> |
| 属性关联 | 每个要素对应一条 dBASE 记录，按记录编号与顺序同几何匹配<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup> |
| 规范 | 《ESRI Shapefile 技术说明》，Esri 白皮书，1998 年 7 月，以开放规范形式发布<sup>[2](https://loc.gov/preservation/digital/formats/fdd/fdd000280.shtml)</sup> |
| 属性限制 | 字段名最长 10 个字符，继承自 dBASE 格式<sup>[3](https://gdal.org/en/stable/drivers/vector/shapefile.html)</sup> |
| 大小限制 | 实践中 .shp 与 .dbf 文件各限 2 GB；按格式的 32 位偏移，原理上上限为 8 GB<sup>[3](https://gdal.org/en/stable/drivers/vector/shapefile.html)</sup> |
| 常见可选文件 | .prj（坐标系）、.sbn/.sbx（空间索引）、.cpg（字符编码）、.xml（元数据）<sup>[4](https://doc.esri.com/en/arcgis-pro/latest/tool-reference/appendices/geoprocessing-considerations-for-shapefile-output.html)</sup> |

## 文件结构

一个 ESRI shapefile 由主文件、索引文件和 dBASE 表组成。主文件支持直接访问，存放长度可变的记录，每条记录给出构成一个形状的各个顶点。索引文件的每个条目记录主文件中对应记录距该文件起始位置的偏移量。dBASE 表包含要素属性，每个要素一条记录；几何与属性之间的一一对应关系以记录编号为基础：属性记录的出现顺序必须与主文件中的记录顺序一致。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup>

所有文件名均遵循 8.3 命名约定。前缀必须以字母或数字开头，后接零至七个字符（字母、数字、下划线或连字符）；因此一个名为 counties 的数据集由 counties.shp、counties.shx 和 counties.dbf 组成。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup>

**主文件。** .shp 文件以一个固定的 100 字节文件头开始，其后是变长记录，每条记录各有固定的 8 字节记录头，存放记录编号和内容长度。记录编号从 1 开始。文件头包含文件代码 9994、版本号 1000、文件总长度、形状类型以及数据的边界框。数据描述字段使用小端序（Intel）字节序，而长度、偏移等文件管理字段使用大端序（Motorola）字节序。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup>

该格式存储有符号 32 位整数（4 字节）和有符号 64 位 IEEE 双精度浮点数（8 字节）。不允许正无穷、负无穷和 NaN 值；小于 −10^38 的浮点数读作“无数据”值，这一约定目前仅用于度量值。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup>

## 形状类型

一个 shapefile 中所有非空形状必须属于同一类型。规范定义了以下代码：0 空形状、1 点、3 折线、5 多边形、8 多点、11 点Z、13 折线Z、15 多边形Z、18 多点Z、21 点M、23 折线M、25 多边形M、28 多点M、31 多重面；直至 33 的取值保留供未来使用。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup>

点是双精度 X、Y 坐标对。折线是一个或多个部分中的有序顶点集，其中每个部分是由两个或更多点构成的一段连通序列；各部分之间可以相连，也可以不相连。多边形由一个或多个环组成，每个环是由四个或更多点构成的闭合、不自交的回路。环的方向具有含义：观察者按顶点顺序沿环行走，其右侧的邻域即为多边形的内部，因此单环多边形为顺时针，定义孔洞的环为逆时针。多边形必须“干净”，环与环之间不得自交。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup>

Z 变体和 M 变体分别增加高程值与度量值，多重面类型则表示三维表面片。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup>

## 属性与辅助文件

dBASE 文件（.dbf）包含所需的任意要素属性或属性键，其他表可与之连接。其格式是 Windows 和 DOS 上许多表格类应用使用的标准 DBF 文件，字段集可任意设置，但须满足三项要求：文件名必须与 Shapefile 文件共享前缀，表中每个形状要素必须对应一条记录，且记录顺序必须与主文件一致。<sup>[5](https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf)</sup>

除三个必需文件外，一个 shapefile 文件簇通常还包含可选组件：.prj 存放坐标系信息，.sbn 与 .sbx 为空间索引，.atx 为属性索引，.ixs 与 .mxs 为地理编码索引，.xml 为 ArcGIS 元数据。.cpg 文件标明 .dbf 文件所用的字符编码，在某些数据共享框架（如面向欧洲水数据的 WISE GIS 指南）中被视为必需文件。<sup>[4](https://doc.esri.com/en/arcgis-pro/latest/tool-reference/appendices/geoprocessing-considerations-for-shapefile-output.html)</sup><sup> • </sup><sup>[6](https://cdr.eionet.europa.eu/help/WFD/WFD_780_2022/GISGuidance/WISE_GIS_Guidance.pdf)</sup>

## 优势与局限

由于 shapefile 没有拓扑数据结构的处理开销，其绘制速度和可编辑性优于拓扑数据源，能够处理相互重叠或非连续的单个要素，通常占用磁盘空间更少，且更易读写。<sup>[1](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)</sup> 广泛的兼容性是这一格式持久不衰的优势：大多数 GIS 软件都能读取和导出 shapefile，.dbf 属性表甚至可以用电子表格打开。<sup>[7](https://felt.com/blog/what-is-a-shapefile)</sup>

其局限源自该格式 20 世纪 80 年代的组件。字段名限 10 个字符，这是继承自 dBASE 格式的约束。<sup>[3](https://gdal.org/en/stable/drivers/vector/shapefile.html)</sup> 该格式明确使用 32 位偏移，因此几何数据不能超过 8 GB（GDAL 的实现将其限制在 4 GB）；为与其他软件兼容，.shp 和 .dbf 文件均不建议超过 2 GB。<sup>[3](https://gdal.org/en/stable/drivers/vector/shapefile.html)</sup> 一个 shapefile 每层只能存储一种几何，且不支持地理数据库中的域、子类型、拓扑规则或关联数据集之间的关系等功能。<sup>[3](https://gdal.org/en/stable/drivers/vector/shapefile.html)</sup><sup> • </sup><sup>[4](https://doc.esri.com/en/arcgis-pro/latest/tool-reference/appendices/geoprocessing-considerations-for-shapefile-output.html)</sup><sup> • </sup><sup>[7](https://felt.com/blog/what-is-a-shapefile)</sup> 由于 .shx 文件是指向 .shp 文件的偏移索引，每次编辑都会同时重写 .shp、.shx 和 .dbf，拆分或重命名组件文件会导致数据损坏。<sup>[8](https://geodocs.io/en/blog/shapefile-vs-geopackage-vs-geojson)</sup><sup> • </sup><sup>[7](https://felt.com/blog/what-is-a-shapefile)</sup>

## 采用与替代方案

美国国会图书馆指出，Esri 于 20 世纪 90 年代推出 shapefile，它很快成为事实上的标准，至今仍被广泛部署，美国国家档案馆、[英国数据服务](https://www.edgepedia.org/zh/uk-data-service)处和荷兰 DANS 均藏有示例研究数据集。<sup>[2](https://loc.gov/preservation/digital/formats/fdd/fdd000280.shtml)</sup> Esri 公开出版该规范以鼓励互操作，称其提供了编写无需 Esri 软件即可创建 shapefile 的程序所需的全部技术信息，并继续将 shapefile 列在其开源的格式规范之中。<sup>[2](https://loc.gov/preservation/digital/formats/fdd/fdd000280.shtml)</sup><sup> • </sup><sup>[9](https://www.esri.com/en-us/arcgis/open-vision/initiatives/standards-specifications)</sup>

现代替代方案直接针对该格式的种种约束。GeoPackage 是基于 SQLite 的单一文件，每个文件可含多个图层，没有 10 字符字段名限制，支持完整的 SQL 数据类型和事务性编辑，在接收方未明确要求 shapefile 时，常被推荐为交换的默认选择。<sup>[10](https://gisconverters.com/guides/geopackage-vs-shapefile.html)</sup><sup> • </sup><sup>[11](https://geobble.com/learn/geopackage-vs-shapefile)</sup> GeoJSON 以单一纯文本文件服务于 Web 与 API 工作流。<sup>[12](https://formats.jarhalab.com/comparisons/shp-vs-geojson)</sup> shapefile 仅存的作用在于兼容性：政府机构、数据门户和遗留桌面工作流仍期待它，因此即便工作数据转向数据库支持的格式，它仍作为交换格式存续。<sup>[11](https://geobble.com/learn/geopackage-vs-shapefile)</sup><sup> • </sup><sup>[7](https://felt.com/blog/what-is-a-shapefile)</sup>

工具链也随之调整。自 GDAL 3.1 起，shapefile 驱动可以读取、创建和编辑 .shz 文件（包含单图层 .shp、.shx、.dbf 及附属文件的 ZIP 压缩包）以及包含多个图层的 .shp.zip 文件，降低了传输过程中组件文件丢失的风险。<sup>[3](https://gdal.org/en/stable/drivers/vector/shapefile.html)</sup>

## References

1. [ESRI Shapefile Technical Description, An ESRI White Paper, July 1998 (J-7855)](https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf)
2. [ESRI Shapefile, Library of Congress Sustainable Formats description](https://loc.gov/preservation/digital/formats/fdd/fdd000280.shtml)
3. [ESRI Shapefile / DBF, GDAL documentation](https://gdal.org/en/stable/drivers/vector/shapefile.html)
4. [Geoprocessing considerations for shapefile output, ArcGIS Pro documentation](https://doc.esri.com/en/arcgis-pro/latest/tool-reference/appendices/geoprocessing-considerations-for-shapefile-output.html)
5. [ESRI Shapefile Technical Description (dBASE file organization), Esri white paper](https://www.esri.com/library/whitepapers/pdfs/shapefile.pdf)
6. [WISE GIS Guidance v 7.0.6, European Environment Agency](https://cdr.eionet.europa.eu/help/WFD/WFD_780_2022/GISGuidance/WISE_GIS_Guidance.pdf)
7. [What's a shapefile in GIS? Uses, limitations, and enterprise workflows, Felt](https://felt.com/blog/what-is-a-shapefile)
8. [Shapefile vs GeoPackage vs GeoJSON: Which to Use, Geodocs](https://geodocs.io/en/blog/shapefile-vs-geopackage-vs-geojson)
9. [Open GIS Standards & Specifications, Esri](https://www.esri.com/en-us/arcgis/open-vision/initiatives/standards-specifications)
10. [GeoPackage vs Shapefile: which should you use?, GISConverter](https://gisconverters.com/guides/geopackage-vs-shapefile.html)
11. [GeoPackage vs Shapefile, Geobble](https://geobble.com/learn/geopackage-vs-shapefile)
12. [SHP vs GeoJSON: Which to Use?, JarhaLab Formats](https://formats.jarhalab.com/comparisons/shp-vs-geojson)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 21, 2026 · Edited: Oct 15, 2026; Oct 21, 2026 · Last review: Oct 21, 2026*

Topic: 地点与地理 › 地理学总论与地理参考资料 › 地图学与地图

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/shapefile

English original: https://www.edgepedia.org/shapefile
