ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / SpatialReference Class / GetWkt2 Method
Example

In This Topic
    GetWkt2 Method (SpatialReference)
    In This Topic
    Gets the well-known text (2) for this instance.
    Syntax
    public string GetWkt2( 
       WktFormatMode wktFormatMode
    )
    Public Function GetWkt2( _
       ByVal wktFormatMode As WktFormatMode _
    ) As String

    Parameters

    wktFormatMode
    Remarks
    The WKT2 string is an OGC-defined international standard for well-known text strings. See Well-known text representation of coordinate reference systems.
    Example
    SpatialReference WKT2
    SpatialReference sr = SpatialReferences.WebMercator;
    
    // Get Esri WKT
    string wkt = sr.Wkt;
    /*
      PROJCS["WGS_1984_Web_Mercator_Auxiliary_Sphere",
       GEOGCS["GCS_WGS_1984",
        DATUM["D_WGS_1984",
         SPHEROID["WGS_1984", 6378137.0, 298.257223563]],
        PRIMEM["Greenwich", 0.0],
        UNIT["Degree", 0.0174532925199433]],
       PROJECTION["Mercator_Auxiliary_Sphere"],
       PARAMETER["False_Easting", 0.0],
       PARAMETER["False_Northing", 0.0],
       PARAMETER["Central_Meridian", 0.0],
       PARAMETER["Standard_Parallel_1", 0.0],
       PARAMETER["Auxiliary_Sphere_Type", 0.0],
       UNIT["Meter", 1.0]]
    */
    
    // Get OGC WKT2
    string wkt2 = sr.GetWkt2(WktFormatMode.None);
    /*
      PROJCRS["WGS_1984_Web_Mercator_Auxiliary_Sphere",
       BASEGEOGCRS["GCS_WGS_1984",
        DYNAMIC[FRAMEEPOCH[1990.5], MODEL["AM0-2"]],
        DATUM["D_WGS_1984",
         ELLIPSOID["WGS_1984", 6378137.0, 298.257223563, LENGTHUNIT["Meter", 1.0]]],
        PRIMEM["Greenwich", 0.0, ANGLEUNIT["Degree", 0.0174532925199433]],
        CS[ellipsoidal, 2],
        AXIS["Latitude (lat)", north, ORDER[1]],
        AXIS["Longitude (lon)", east, ORDER[2]],
        ANGLEUNIT["Degree", 0.0174532925199433]],
       CONVERSION["Mercator_Auxiliary_Sphere",
        METHOD["Mercator_Auxiliary_Sphere"],
        PARAMETER["False_Easting", 0.0, LENGTHUNIT["Meter", 1.0]],
        PARAMETER["False_Northing", 0.0, LENGTHUNIT["Meter", 1.0]],
        PARAMETER["Central_Meridian", 0.0, ANGLEUNIT["Degree", 0.0174532925199433]],
        PARAMETER["Standard_Parallel_1", 0.0, ANGLEUNIT["Degree", 0.0174532925199433]],
        PARAMETER["Auxiliary_Sphere_Type", 0.0]],
       CS[Cartesian, 2],
       AXIS["Easting (X)", east, ORDER[1]],
       AXIS["Northing (Y)", north, ORDER[2]],
       LENGTHUNIT["Meter", 1.0]]
    */
    
    // You can create a spatial reference with the Esri WKT string or the OCG WKT2 string
    sr = SpatialReferenceBuilder.CreateSpatialReference(wkt2);
    
    // Get OGC WKT2 including authority in top-level objects
    // In this case the authority is written as ID["EPSG",3857]
    wkt2 = sr.GetWkt2(WktFormatMode.AuthorityTop);
    /*  
      PROJCRS["WGS_1984_Web_Mercator_Auxiliary_Sphere",
       BASEGEOGCRS["GCS_WGS_1984",
       DYNAMIC[FRAMEEPOCH[1990.5],MODEL["AM0-2"]],
       DATUM["D_WGS_1984",
        ELLIPSOID["WGS_1984",6378137.0,298.257223563,LENGTHUNIT["Meter",1.0]]],
       PRIMEM["Greenwich",0.0,ANGLEUNIT["Degree",0.017453292519943295]],
       CS[ellipsoidal,2],
       AXIS["Latitude (lat)",north,ORDER[1]],
       AXIS["Longitude(lon)",east,ORDER[2]],
       ANGLEUNIT["Degree",0.017453292519943295]],
       CONVERSION["Mercator_Auxiliary_Sphere",
        METHOD["Mercator_Auxiliary_Sphere"],
        PARAMETER["False_Easting",0.0,LENGTHUNIT["Meter",1.0]],
        PARAMETER["False_Northing",0.0,LENGTHUNIT["Meter",1.0]],
        PARAMETER["Central_Meridian",0.0,ANGLEUNIT["Degree",0.017453292519943295]],
        PARAMETER["Standard_Parallel_1",0.0,ANGLEUNIT["Degree",0.017453292519943295]],
        PARAMETER["Auxiliary_Sphere_Type",0.0]],
        CS[Cartesian,2],
        AXIS["Easting (X)",east,ORDER[1]],
        AXIS["Northing (Y)",north,ORDER[2]],
        LENGTHUNIT["Meter",1.0],
        ID["EPSG",3857]]
    */
    
    // Get OGC WKT2 including authority in all objects
    // Authority is written as ID["ESPG",<id>] or ID["Esri",<id>]
    wkt2 = sr.GetWkt2(WktFormatMode.AuthorityAll);
    /*
      PROJCRS["WGS_1984_Web_Mercator_Auxiliary_Sphere",
       BASEGEOGCRS["GCS_WGS_1984",
        DYNAMIC[FRAMEEPOCH[1990.5],MODEL["AM0-2"]],
        DATUM["D_WGS_1984",
         ELLIPSOID["WGS_1984",6378137.0,298.257223563,LENGTHUNIT["Meter",1.0,ID["EPSG",9001]],ID["EPSG",7030]],
         ID["EPSG",6326]],
        PRIMEM["Greenwich",0.0,ANGLEUNIT["Degree",0.017453292519943295,ID["EPSG",9102]],ID["EPSG",8901]],
        CS[ellipsoidal,2],
        AXIS["Latitude (lat)",north,ORDER[1]],
        AXIS["Longitude(lon)",east,ORDER[2]],
        ANGLEUNIT["Degree",0.017453292519943295,ID["EPSG",9102]],ID["EPSG",4326]],
        CONVERSION["Mercator_Auxiliary_Sphere",
         METHOD["Mercator_Auxiliary_Sphere",ID["Esri",43104]],
         PARAMETER["False_Easting",0.0,LENGTHUNIT["Meter",1.0,ID["EPSG",9001]],ID["Esri",100001]],
         PARAMETER["False_Northing",0.0,LENGTHUNIT["Meter",1.0,ID["EPSG",9001]],ID["Esri",100002]],
         PARAMETER["Central_Meridian",0.0,ANGLEUNIT["Degree",0.017453292519943295,ID["EPSG",9102]],ID["Esri",100010]],
         PARAMETER["Standard_Parallel_1",0.0,ANGLEUNIT["Degree",0.017453292519943295,ID["EPSG",9102]],ID["Esri",100025]],
         PARAMETER["Auxiliary_Sphere_Type",0.0,ID["Esri",100035]]],
        CS[Cartesian,2],
        AXIS["Easting(X)",east,ORDER[1]],
        AXIS["Northing (Y)",north,ORDER[2]],
        LENGTHUNIT["Meter",1.0,ID["EPSG",9001]],
        ID["EPSG",3857]]
    */
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.2 or higher.
    See Also