ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Core.Geometry Namespace / SpatialReferenceBuilder Class / SpatialReferenceBuilder Constructor / SpatialReferenceBuilder Constructor(String)
The well-known text that represents the spatial reference.
Example

In This Topic
    SpatialReferenceBuilder Constructor(String)
    In This Topic
    Creates a new instance of the SpatialReferenceBuilder class. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public SpatialReferenceBuilder( 
       string wkt
    )
    Public Function New( _
       ByVal wkt As String _
    )

    Parameters

    wkt
    The well-known text that represents the spatial reference.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Example
    Construct a SpatialReference - from a string
    // Use a builder convenience method or use a builder constructor.
    
    string wkt = "GEOGCS[\"MyGCS84\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Radian\",1.0]]";
    
    // SpatialReferenceBuilder convenience methods don't need to run on the MCT.
    SpatialReference sr = SpatialReferenceBuilder.CreateSpatialReference(wkt);
    
    // SpatialReferenceBuilder constructors need to run on the MCT.
    ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
    {
      using (SpatialReferenceBuilder builder = new SpatialReferenceBuilder(wkt))
      {
        // do something with the builder
    
        SpatialReference anotherSR = builder.ToSpatialReference();
      }
    });
    
    Construct a SpatialReference with a custom PCS - from a string
    // Use a builder convenience method or use a builder constructor.
    
    // Custom PCS, Predefined GCS
    string customWkt = "PROJCS[\"WebMercatorMile\",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[\"Mile\",1609.344000614692]]";
    
    // Builder convenience methods don't need to run on the MCT.
    SpatialReference spatialReference = SpatialReferenceBuilder.CreateSpatialReference(customWkt);
    // SpatialReferenceBuilder properties
    //   spatialReference.Wkt == customWkt
    //   spatialReference.Wkid == 0
    //   spatialReference.VcsWkid == 0
    //   spatialReference.GcsWkid == 4326
    
    SpatialReference gcs = spatialReference.Gcs;
    // gcs.Wkid == 4326
    // gcs.IsGeographic == true
    // spatialReference.GcsWkt == gcs.Wkt
    
    // SpatialReferenceBuilder constructors need to run on the MCT.
    ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
    {
      using (SpatialReferenceBuilder sb = new SpatialReferenceBuilder(customWkt))
      {
        // do something with the builder
    
        spatialReference = sb.ToSpatialReference();
      }
    });
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also