Main Content


Information about shapefile



info = shapeinfo(filename) returns a structure, info, whose fields contain information about the contents of a file in shapefile format. filename can be the base name or the full name of any one of the component files. shapeinfo reads all three files as long as they exist in the same folder and the unit of length or angle is not specified. If the main file (with extension .SHP) is missing, shapeinfo returns an error. If either of the other files is missing, shapeinfo returns a warning.


collapse all

Get projected or geographic CRS information from a shapefile by using the shapeinfo function.

First, return information about a shapefile as a structure. For this example, specify a shapefile that uses projected coordinates. Then, get information about the coordinate reference system by querying the CoordinateReferenceSystem field of the structure.

S = shapeinfo('boston_placenames.shp');
ans = 
  projcrs with properties:

                    Name: "NAD83 / Massachusetts Mainland"
           GeographicCRS: [1x1 geocrs]
        ProjectionMethod: "Lambert Conic Conformal (2SP)"
              LengthUnit: "meter"
    ProjectionParameters: [1x1]

Note that the value of the CoordinateReferenceSystem field is a projcrs object because the shapefile uses projected coordinates.

Input Arguments

collapse all

File name of the shapefile, specified as a string scalar or character vector. filename can be the base name or the full name of any one of the component files.

Output Arguments

collapse all

Information about shapefile contents, returned as a structure contains the following fields.


Char array containing the names of the files that were read


Character vector containing the shape type


Numerical array of size 2-by-N that specifies the minimum (row 1) and maximum (row 2) values for each dimension of the spatial data in the shapefile


Structure array of size 1-by-numAttributes that describes the attributes of the data. The structure contains these fields:

  • Name — Character vector containing the attribute name as given in the xBASE table

  • Type — Character vector specifying the MATLAB® class of the attribute data returned by shaperead. The following attribute (xBASE) types are supported: Numeric, Floating, Character, and Date


The number of spatial features in the shapefile


Coordinate reference system (CRS), returned as a geocrs or projcrs object. The value of CoordinateReferenceSystem depends on the data contained in the file:

  • If the data is referenced to a geographic coordinate system, then CoordinateReferenceSystem is a geocrs object.

  • If the data is referenced to a projected coordinate system, then CoordinateReferenceSystem is a projcrs object.

  • If the file does not contain valid coordinate reference system information, then CoordinateReferenceSystem is empty.

More About

collapse all

Shapefile format

Data files in the shapefile format store vector data using multiple files: a main file (.shp), an index file (.shx), and an attribute file (.dbf). All the files have the same base name, for example, myfile.shp, myfile.shx, and myfile.dbf.

Version History

Introduced before R2006a