Main Content

isequal

Compare two projcrs or geocrs objects for equivalence

Description

example

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

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

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

The isequal function does not consider CRS names.

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

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

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",
         DATUM["World Geodetic System 1984",
             ELLIPSOID["WGS 84",6378137,298.257223563,
                 LENGTHUNIT["metre",1]]],
         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

First coordinate reference system, specified as a projcrs or geocrs object.

Second coordinate reference system, specified as a projcrs or geocrs object.

Tips

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

See Also

Objects

Introduced in R2021a