주요 콘텐츠

isequal

R2026b

Compare projcrs, geocrs, or vertcrs objects for equivalence

Description

tf = isequal(crs1,crs2) returns logical 1 (true) if the coordinate reference systems (CRSs) are equivalent. Otherwise, it returns logical 0 (false).

  • Two projcrs objects are equivalent if they have the same geographic CRS, projection method, projection parameters, length unit, and vertical CRS.

  • Two geocrs objects are equivalent if they have the same datum name, reference spheroid, prime meridian, angle unit, and vertical CRS.

  • Two vertcrs objects are equivalent if they have the same datum, direction, and length unit.

The isequal function does not consider CRS names.

example

tf = isequal(crs1,crs2,...,crsN) returns logical 1 (true) if all the CRSs are equivalent.

Examples

collapse all

Get information about two raster data sets using the georasterinfo function. Assign their coordinate reference systems to variables. In this case, the coordinate reference systems are projcrs objects.

info1 = georasterinfo("MtWashington-ft.grd");
info2 = georasterinfo("MountDartmouth-ft.grd");
 
crs1 = info1.CoordinateReferenceSystem;
crs2 = info2.CoordinateReferenceSystem;

Compare the coordinate reference systems.

tf = isequal(crs1,crs2)
tf = logical
   1

Two coordinate reference systems can be equivalent, even if the strings returned by the wktstring function are not identical.

Return information about a shapefile as a structure. Find the coordinate reference system by querying the CoordinateReferenceSystem field.

info = shapeinfo("landareas.shp");
g1 = info.CoordinateReferenceSystem
g1 = 
  geocrs with properties:

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

Create a second coordinate reference system by using the geocrs function.

g2 = geocrs(4326)
g2 = 
  geocrs with properties:

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

The coordinate reference systems have the same datum name, reference spheroid, prime meridian, and angle unit. Therefore, the coordinate reference systems are equivalent.

isequal(g1,g2)
ans = logical
   1

Note that the WKT strings are not identical. The string for g2 contains additional information about the area of use ("USAGE") and authority code ("ID").

wktstring(g1,Format="formatted")
ans = 
    "GEOGCRS["WGS 84",
         DATUM["World Geodetic System 1984",
             ELLIPSOID["WGS 84",6378137,298.257223563,
                 LENGTHUNIT["metre",1]],
             ID["EPSG",6326]],
         PRIMEM["Greenwich",0,
             ANGLEUNIT["Degree",0.0174532925199433]],
         CS[ellipsoidal,2],
             AXIS["longitude",east,
                 ORDER[1],
                 ANGLEUNIT["Degree",0.0174532925199433]],
             AXIS["latitude",north,
                 ORDER[2],
                 ANGLEUNIT["Degree",0.0174532925199433],
                 ID["EPSG",7030]]]"

wktstring(g2,Format="formatted")
ans = 
    "GEOGCRS["WGS 84",
         ENSEMBLE["World Geodetic System 1984 ensemble",
             MEMBER["World Geodetic System 1984 (Transit)"],
             MEMBER["World Geodetic System 1984 (G730)"],
             MEMBER["World Geodetic System 1984 (G873)"],
             MEMBER["World Geodetic System 1984 (G1150)"],
             MEMBER["World Geodetic System 1984 (G1674)"],
             MEMBER["World Geodetic System 1984 (G1762)"],
             MEMBER["World Geodetic System 1984 (G2139)"],
             MEMBER["World Geodetic System 1984 (G2296)"],
             ELLIPSOID["WGS 84",6378137,298.257223563,
                 LENGTHUNIT["metre",1]],
             ENSEMBLEACCURACY[2.0]],
         PRIMEM["Greenwich",0,
             ANGLEUNIT["degree",0.0174532925199433]],
         CS[ellipsoidal,2],
             AXIS["geodetic latitude (Lat)",north,
                 ORDER[1],
                 ANGLEUNIT["degree",0.0174532925199433]],
             AXIS["geodetic longitude (Lon)",east,
                 ORDER[2],
                 ANGLEUNIT["degree",0.0174532925199433]],
         USAGE[
             SCOPE["Horizontal component of 3D system."],
             AREA["World."],
             BBOX[-90,-180,90,180]],
         ID["EPSG",4326]]"

Input Arguments

collapse all

Coordinate reference system, specified as a projcrs, geocrs, or vertcrs object.

Tips

  • If you expect two CRSs to be equivalent, but the isequal function returns 0 (false), you can inspect the WKT strings for differences using the wktstring function.

  • To compare only the 2-D parts of geographic or projected CRSs, set their VerticalCRS properties to [] before comparing them.

Version History

Introduced in R2021a

expand all

See Also

Objects