Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Shapefile

From Wikipedia, the free encyclopedia

Geospatial vector data format
Shapefile
A vector map, with points, polylines and polygons
Filename extension.shp,.shx,.dbf
Internet media type
application/vnd.shp
Developed byEsri
Type of formatGIS
StandardShapefile Technical Description

Theshapefile format is a geospatial vectordata format for geographic information system (GIS) software. It is developed and regulated byEsri as a mostlyopen specification for data interoperability among Esri and otherGIS software products.[1] The shapefile format can spatially describevector features:points,lines, andpolygons, representing, for example,water wells,rivers, andlakes. Each item usually hasattributes that describe it, such asname ortemperature.

Overview

[edit]

The shapefile format is a digital vector storage format for storing geographic location and associated attribute information. This format lacks the capacity to storetopological information. The shapefile format was introduced withArcView GIS version 2 in the early 1990s. It is now possible to read and write geographical datasets using the shapefile format with a wide variety of software.

The shapefile format stores the geometry as primitive geometric shapes like points, lines, and polygons. These shapes, together with data attributes that are linked to each shape, create the representation of the geographic data. The term "shapefile" is quite common, but the format consists of a collection of files with a common filename prefix, stored in the samedirectory. The threemandatory files havefilename extensions.shp,.shx, and.dbf. The actualshapefile relates specifically to the.shp file, but alone is incomplete for distribution as the other supporting files are required. In line with theESRI Shapefile Technical Description,[1] legacy GIS software may expect that the filename prefix be limited to eight characters to conform to the DOS8.3 filename convention, though modern software applications accept files with longer names.

Mandatory files

[edit]
.shp
Shape format; the feature geometry itself.
Content-type:application/vnd.shp
.shx
Shape index format; a positional index of the feature geometry to allow seeking forwards and backwards quickly.
Content-type:application/vnd.shp.shx
.dbf
Attribute format; columnar attributes for each shape, indBase IV format.
Content-type:application/vnd.dbf

Other files

[edit]
  • .prj — projection description, using awell-known text representation of coordinate reference systems {content-type: text/plain OR application/text}
  • .sbn and.sbx — aspatial index of the features {content-type: application/vnd.shp}
  • .fbn and.fbx — a spatial index of the features that are read-only {content-type: application/vnd.shp}
  • .ain and.aih — an attribute index of the active fields in a table {content-type: application/vnd.shp}
  • .ixs — a geocoding index for read-write datasets {content-type: application/vnd.shp}
  • .mxs — a geocoding index for read-write datasets (ODB format) {content-type: application/vnd.shp}
  • .atx — an attribute index for the.dbf file in the form ofshapefile.columnname.atx (ArcGIS 8 and later) {content-type:application/vnd.shp }
  • .shp.xmlgeospatial metadata in XML format, such asISO 19115 or otherXML schema {content-type: application/fgdc+xml}
  • .cpg — used to specify thecode page (only for.dbf) for identifying thecharacter encoding to be used {content-type:text/plain ORapplication/vnd.shp }
  • .qix — an alternativequadtree spatial index used byMapServer andGDAL/OGR software {content-type: application/vnd.shp}

In each of the.shp,.shx, and.dbf files, the shapes in each file correspond to each other in sequence (i.e., the first record in the.shp file corresponds to the first record in the.shx and.dbf files, etc.). The.shp and.shx files have various fields with differentendianness, so an implementer of the file formats must be very careful to respect the endianness of each field and treat it properly.

File formats

[edit]

Shapefile shape format (.shp)

[edit]

The main file (.shp) contains the geometry data. Geometry of a given feature is stored as a set of vector coordinates.[1]: 5  Thebinary file consists of a single fixed-lengthheader followed by one or more variable-lengthrecords. Each of the variable-length records includes a record-header component and a record-contents component. A detailed description of the file format is given in theESRI Shapefile Technical Description.[1] This format should not be confused with theAutoCAD shape font source format, which shares the.shp extension.

The 2D axis ordering of coordinate data assumes aCartesian coordinate system, using the order (X Y) or (Easting Northing). This axis order is consistent forGeographic coordinate systems, where the order is similarly (longitude latitude). Geometries may also support 3- or 4-dimensional Z and M coordinates, forelevation and measure, respectively. A Z-dimension stores the elevation of each coordinate in3D space, which can be used for analysis or for visualisation of geometries using3D computer graphics. The user-defined M dimension can be used for one of many functions, such as storinglinear referencing measures or relativetime of a feature in4D space.

The main file header is fixed at 100 bytes in length and contains 17 fields; nine 4-byte (32-bit signed integer or int32) integer fields followed by eight 8-byte (double) signed floating point fields:

Shapefile headers

[edit]
Header of a .shp file format
BytesTypeEndiannessUsage
0–3int32bigFile code (always hex value0x0000270a)
4–23int32bigUnused; five uint32
24–27int32bigFile length (in 16-bit words, including the header)
28–31int32littleVersion
32–35int32littleShape type (see reference below)
36–67doublelittleMinimum bounding rectangle (MBR) of all shapes contained within the dataset; four doubles in the following order: min X, min Y, max X, max Y
68–83doublelittleRange of Z; two doubles in the following order: min Z, max Z
84–99doublelittleRange of M; two doubles in the following order: min M, max M

Shapefile record headers

[edit]

The file then contains any number of variable-length records. Each record is prefixed with a record header of 8 bytes:

BytesTypeEndiannessUsage
0–3int32bigRecord number (1-based)
4–7int32bigRecord length (in 16-bit words)

Shapefile records

[edit]

Following the record header is the actual record:

BytesTypeEndiannessUsage
0–3int32littleShape type (see reference below)
4–Shape content

The variable-length record contents depend on the shape type, which must be either the shape type given in the file header or Null. The following are the possible shape types:

ValueShape typeFields
0Null shapeNone
1PointX, Y
3PolylineMBR, Number of parts, Number of points, Parts, Points
5PolygonMBR, Number of parts, Number of points, Parts, Points
8MultiPointMBR, Number of points, Points
11PointZX, Y, Z

Optional: M

13PolylineZMandatory: MBR, Number of parts, Number of points, Parts, Points, Z range, Z array

Optional: M range, M array

15PolygonZMandatory: MBR, Number of parts, Number of points, Parts, Points, Z range, Z array

Optional: M range, M array

18MultiPointZMandatory: MBR, Number of points, Points, Z range, Z array

Optional: M range, M array

21PointMX, Y, M
23PolylineMMandatory: MBR, Number of parts, Number of points, Parts, Points

Optional: M range, M array

25PolygonMMandatory: MBR, Number of parts, Number of points, Parts, Points

Optional: M range, M array

28MultiPointMMandatory: MBR, Number of points, Points

Optional Fields: M range, M array

31MultiPatchMandatory: MBR, Number of parts, Number of points, Parts, Part types, Points, Z range, Z array

Optional: M range, M array

Shapefile shape index format (.shx)

[edit]

The index contains positional index of the feature geometry and the same 100-byte header as the.shp file, followed by any number of 8-byte fixed-length records which consist of the following two fields:

BytesTypeEndiannessUsage
0–3int32bigRecord offset (in 16-bit words)
4–7int32bigRecord length (in 16-bit words)

Using this index, it is possible to seek backwards in the shapefile by, first, seeking backwards in the shape index (which is possible because it uses fixed-length records), then reading the record offset, and using that offset to seek to the correct position in the.shp file. It is also possible to seek forwards an arbitrary number of records using the same method.

It is possible to generate the complete index file given a lone.shp file. However, since a shapefile is supposed to always contain an index, doing so counts as repairing a corrupt file.[2]

Shapefile attribute format (.dbf)

[edit]
Main article:.dbf

This file stores the attributes for each shape; it uses thedBase IV format. The format is public knowledge, and has been implemented in many dBase clones known asxBase. The open-source shapefile C library, for example, calls its format "xBase" even though it's plain dBase IV.[3]

The names and values of attributes are not standardized, and will be different depending on the source of the shapefile.

Shapefile spatial index format (.sbn)

[edit]

This is a binaryspatial index file, which is used only by Esri software. The format is not documented by Esri. However it has been reverse-engineered and documented by the open source community. The 100-byte header is similar to the one in.shp.[4] It is not currently implemented by other vendors. The.sbn file is not strictly necessary, since the.shp file contains all of the information necessary to successfully parse the spatial data.

Limitations

[edit]

The shapefile format has a number of limitations.[5]

Topology and the shapefile format

[edit]

The shapefile format does not have the ability to storetopological relationships between shapes. The ESRI ArcInfocoverages and manygeodatabases do have the ability to store feature topology.

Data storage

[edit]

The size of both.shp and.dbf component files cannot exceed 2 GB (or 231 bytes) — around 70 million point features at best.[6] The maximum number of feature for other geometry types varies depending on the number of vertices used.

The attribute database format for the.dbf component file is based on an olderdBase standard. This database format inherently has a number of limitations:[6]

  • While the currentdBase standard, andGDAL/OGR (the main open source software library for reading and writing shapefile format datasets) supportnull values, ESRI software represents these values as zeros — a very serious issue for analyzing quantitative data, as it may skew representation and statistics if null quantities are represented as zero
  • Poor support forUnicode field names or field storage
  • Maximum length of field names is 10 characters
  • Maximum number of fields is 255
  • Supported field types are: floating point (13 character storage), integer (4 or 9 character storage), date (no time storage; 8 character storage), and text (maximum 254 character storage)
  • Floating point numbers may contain rounding errors since they are stored as text

Mixing shape types

[edit]

Because the shape type precedes each geometry record, a shapefile is technically capable of storing a mixture of different shape types. However, the specification states, "All the non-Null shapes in a shapefile are required to be of the same shape type." Therefore, this ability to mix shape types must be limited to interspersing null shapes with the single shape type declared in the file's header. A shapefile must not contain both polyline and polygon data, for example, the descriptions for a well (point), a river (polyline), and a lake (polygon) would be stored in three separate datasets.

See also

[edit]

References

[edit]
  1. ^abcdESRI (July 1998)."ESRI Shapefile Technical Description"(PDF). Retrieved4 July 2007.
  2. ^Rollason, Ed."qgis - Creating missing .shx file?".Geographic Information Systems Stack Exchange.
  3. ^"Shapefile C Library V1.2".
  4. ^"SBN Format"(PDF). 4 October 2011. Archived fromthe original(PDF) on 13 August 2016. Retrieved21 June 2023.
  5. ^Cepicky, Jachym (2017)."Switch from Shapefile".switchfromshapefile.org.
  6. ^ab"ArcGIS Desktop 9.3 Help – Geoprocessing considerations for shapefile output". Esri. 24 April 2009.

External links

[edit]
Retrieved from "https://en.wikipedia.org/w/index.php?title=Shapefile&oldid=1279059084"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp