geocrs

Geographic coordinate reference system

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.

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

There are several ways to create geographic CRS objects, including:

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

  • 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

example

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.

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 pair.

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

For information on valid EPSG codes, see the EPSG home page.

Authority, specified as 'EPSG', 'ESRI', or 'IGNF'. This argument specifies which authority the geocrs function uses to determine the properties of the created geographic CRS object. 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

This property is read-only.

CRS name, returned as a string scalar.

Data Types: string

This property is read-only.

Datum name, returned as a string scalar.

Data Types: string

This property is read-only.

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

Data Types: string

This property is read-only.

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

Data Types: double

This property is read-only.

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

Data Types: string

Object Functions

wktstringWell-known text string

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: [1x1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"

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

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

             Name: "GCS_Guam_1963"
            Datum: "Guam 1963"
         Spheroid: [1x1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"

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

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

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

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: [1x1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"

Import raster data as an array and a geographic reference object using the readgeoraster function. Then, get the geographic CRS by querying the GeographicCRS property of the reference object.

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

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

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"
            Datum: "World Geodetic System 1984"
         Spheroid: [1x1 referenceEllipsoid]
    PrimeMeridian: 0
        AngleUnit: "degree"

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

Tips

Even when the property values of two geocrs objects are the same, the WKT for the objects might be different. As a result, when you compare two geocrs objects by using the isequal function, the function might return 0 (false), even when the property values are the same. Compare geocrs objects by directly comparing their property values instead.

See Also

Functions

Objects

External Websites

Introduced in R2020b