ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / ImportFromWKT Method
A combination of WktImportFlags which determines how the geometry is imported.
The input WKT string. The string must be OGC compliant.
The spatial reference of the output geometry.
Example

In This Topic
    ImportFromWKT Method (GeometryEngine)
    In This Topic
    Creates a geometry from the input well-known text string.
    Syntax

    Parameters

    importFlags
    A combination of WktImportFlags which determines how the geometry is imported.
    wktString
    The input WKT string. The string must be OGC compliant.
    spatialReference
    The spatial reference of the output geometry.

    Return Value

    A Geometry that corresponds to the wktString.
    Exceptions
    ExceptionDescription
    wktString is null or empty.
    Example
    Import and Export Geometries to well-known Text
    // create a point with z, m
    MapPoint point = MapPointBuilderEx.CreateMapPoint(
             100, 200, 300, 400, SpatialReferences.WebMercator);
    
    // set the flags
    WktExportFlags wktExportFlags = WktExportFlags.WktExportDefaults;
    WktImportFlags wktImportFlags = WktImportFlags.WktImportDefaults;
    
    // export and import
    string wktString = GeometryEngine.Instance.ExportToWKT(wktExportFlags, point);
    MapPoint importPoint = GeometryEngine.Instance.ImportFromWKT(
          wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
    
    double x = importPoint.X;       // x = 100
    double y = importPoint.Y;       // y = 200
    bool hasZ = importPoint.HasZ;   // hasZ = true
    double z = importPoint.Z;       // z = 300
    bool hasM = importPoint.HasM;   // hasM = true
    double m = importPoint.M;       // m = 400
    
    // export without z
    WktExportFlags exportFlagsNoZ = WktExportFlags.WktExportStripZs;
    wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoZ, point);
    importPoint = GeometryEngine.Instance.ImportFromWKT(
      wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
    
    x = importPoint.X;        // x = 100
    y = importPoint.Y;        // y = 200
    hasZ = importPoint.HasZ;  // hasZ = false
    z = importPoint.Z;        // z = 0
    hasM = importPoint.HasM;  // hasM = true
    m = importPoint.M;        // m = 400
    
    // export without m
    WktExportFlags exportFlagsNoM = WktExportFlags.WktExportStripMs;
    wktString = GeometryEngine.Instance.ExportToWKT(exportFlagsNoM, point);
    importPoint = GeometryEngine.Instance.ImportFromWKT(
      wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
    
    x = importPoint.X;        // x = 100
    y = importPoint.Y;        // y = 200
    hasZ = importPoint.HasZ;  // hasZ = true
    z = importPoint.Z;        // z = 300
    hasM = importPoint.HasM;  // hasM = false
    m = importPoint.M;        // m = Nan
    
    // export without z, m
    wktString = GeometryEngine.Instance.ExportToWKT(
      exportFlagsNoZ | exportFlagsNoM, point);
    importPoint = GeometryEngine.Instance.ImportFromWKT(
      wktImportFlags, wktString, SpatialReferences.WebMercator) as MapPoint;
    
    x = importPoint.X;        // x = 100
    y = importPoint.Y;        // y = 200
    hasZ = importPoint.HasZ;  // hasZ = false
    z = importPoint.Z;        // z = 0
    hasM = importPoint.HasM;  // hasM = false
    m = importPoint.M;        // m = Nan
    
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also