Main Content

geocrs

R2026b

Geographic coordinate reference system object

Description

A geographic coordinate reference system (CRS) provides information that assigns latitude, longitude, and height coordinates to physical locations. Geographic CRSs consist of a datum, a prime meridian, and an angular unit of measurement. Optionally, a geocrs object can represent a compound CRS or a 3-D geographic CRS by including a vertical CRS.

Projected CRSs consist of a geographic CRS and several parameters that are used to transform coordinates to and from the geographic CRS. For more information about projected CRSs, see projcrs.

Creation

You can create a geographic CRS object in these ways:

  • Import raster data using functions such as readgeoraster or wmsread, and then query the GeographicCRS property of the returned raster reference object.

  • Import vector data by using the readgeotable function, and then query the GeographicCRS property of the shape objects in the returned geospatial table.

  • Get information about a shapefile using the shapeinfo function, and then query the CoordinateReferenceSystem field of the returned structure.

  • Access the geographic CRS of a projected CRS by querying the GeographicCRS property of a projcrs object.

  • Use the geocrs function (described here).

Description

g = geocrs(code) creates a geographic CRS object using the EPSG code specified by code.

example

g = geocrs(code,Authority=authority) creates a geographic CRS object using the specified code and authority.

example

g = geocrs(wkt) creates a geographic CRS object using a specified well-known text (WKT) string representation.

example

Input Arguments

expand all

Geographic CRS code, specified as a positive integer, string scalar, or character vector. By default, the geocrs function assumes the code argument refers to an EPSG code. To specify other types of codes, use the Authority name-value argument.

To refer to an EPSG or ESRI code, specify this argument as a positive integer. To refer to an IGNF code, specify this argument as a string scalar or character vector.

For information about valid EPSG, ESRI, and IGNF codes, see the Spatial Reference home page.

Organization that manages the definition of the CRS, specified as "EPSG", "ESRI", or "IGNF". Each organization maintains a list of codes associated with specific CRSs.

If you do not specify an authority, then the geocrs function uses "EPSG".

Well-known text (WKT), specified as a string scalar or character vector. You can use well-known text in either the WKT 1 or WKT 2 standard.

Properties

expand all

CRS name, specified as a string scalar.

Changing the value of the VerticalCRS property can automatically change the value of this property to "". If you manually change the value of the Name property, then changing the VerticalCRS property does not automatically change this property.

Data Types: string

This property is read-only.

Datum name, represented as a string scalar.

Data Types: string

This property is read-only.

Reference spheroid used by the datum, represented as a referenceEllipsoid object, referenceSphere object, or oblateSpheroid object.

This property is read-only.

Longitude origin offset from Greenwich, represented as a scalar. The units of the PrimeMeridian property match the value of the AngleUnit property.

Data Types: double

This property is read-only.

Angle unit, represented as a string scalar. The typical values are "degree" and "radian".

Data Types: string

Since R2026b

Vertical CRS, represented as one of these options:

  • [] — The geographic CRS represents a 2-D geographic CRS.

  • A vertcrs object — The geographic CRS represents a compound CRS or a 3-D geographic CRS.

Object Functions

wktstringWell-known text string
isequalCompare projcrs, geocrs, or vertcrs objects for equivalence

Examples

collapse all

Create a geographic CRS object by specifying an EPSG code.

g = geocrs(6668)
g = 
  geocrs with properties:

             Name: "JGD2011"
            Datum: "Japanese Geodetic Datum 2011"
         Spheroid: [1×1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"
      VerticalCRS: []

Create a geographic CRS object from an ESRI code by using the Authority name-value argument.

g = geocrs(37220,Authority="ESRI")
g = 
  geocrs with properties:

             Name: "GCS_Guam_1963"
            Datum: "D_Guam_1963"
         Spheroid: [1×1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"
      VerticalCRS: []

Create a geographic CRS object from an IGNF code by using the Authority name-value argument. Specify the code using a string scalar or character vector.

g = geocrs("RGFG95G",Authority="IGNF")
g = 
  geocrs with properties:

             Name: "RGFG95 geographiques (dms)"
            Datum: "Reseau Geodesique Francais Guyane 1995"
         Spheroid: [1×1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"
      VerticalCRS: []

Import a WKT projection file as a character vector using the fileread function. Then, create a geographic CRS object by specifying the vector.

wkt = fileread("landareas.prj");
g = geocrs(wkt)
g = 
  geocrs with properties:

             Name: "WGS 84"
            Datum: "World Geodetic System 1984"
         Spheroid: [1×1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"
      VerticalCRS: []

Import elevation data [1] as an array and a geographic reference object. Get the geographic CRS by querying the GeographicCRS property of the reference object.

[Z,R] = readgeoraster("n39_w106_3arc_v2.dt1");
gcrs = R.GeographicCRS
gcrs = 
  geocrs with properties:

             Name: "WGS 84 + EGM96 geoid height"
            Datum: "World Geodetic System 1984"
         Spheroid: [1×1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"
      VerticalCRS: [1×1 vertcrs]

The elevation data is referenced to a compound CRS, which consists of a 2-D geographic CRS and a vertical CRS. Get the vertical CRS by querying the VerticalCRS property of the geocrs object.

vcrs = gcrs.VerticalCRS
vcrs = 
  vertcrs with properties:

          Name: "EGM96 height"
         Datum: "EGM96 geoid"
     Direction: "up"
    LengthUnit: "meter"

Alternatively, return information about the same file as a RasterInfo object using the georasterinfo function. Then, get the geographic CRS by querying the CoordinateReferenceSystem property of the object.

info = georasterinfo("n39_w106_3arc_v2.dt1");
info.CoordinateReferenceSystem
ans = 
  geocrs with properties:

             Name: "WGS 84 + EGM96 geoid height"
            Datum: "World Geodetic System 1984"
         Spheroid: [1×1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"
      VerticalCRS: [1×1 vertcrs]

[1] The elevation data used in this example is from the US Geological Survey.

Find the reference ellipsoid for a geographic CRS by creating a geocrs object and accessing its Spheroid property.

g = geocrs(4957);
g.Spheroid
ans = 
referenceEllipsoid with defining properties:

                 Code: 7019
                 Name: 'GRS 1980'
           LengthUnit: 'meter'
        SemimajorAxis: 6378137
        SemiminorAxis: 6356752.31414036
    InverseFlattening: 298.257222101
         Eccentricity: 0.0818191910428158

  and additional properties:

    Flattening
    ThirdFlattening
    MeanRadius
    SurfaceArea
    Volume

Version History

Introduced in R2020b

expand all