ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / WktExportFlags Enumeration
Example Example

In This Topic
    WktExportFlags Enumeration
    In This Topic
    Specifies the flags that control the behavior of the GeometryEngine.ExportToWKT method.
    Syntax
    Members
    MemberDescription
    WktExportDefaults Exports the geometry as is based on its type. Attributes such as Z and M values are exported.
    WktExportFailIfNotSimple Throws an exception if the geometry is not topologically simple. Applies only to Polygon and Polyline geometry types.
    WktExportLineString Exports a MultiLineString with one LineString as a LineString.
    WktExportMultiLineString Exports a LineString as a MultiLineString
    WktExportMultipoint Exports a Point as a Multipoint.
    WktExportMultiPolygon Exports a Polygon as a MultiPolygon.
    WktExportPoint Exports a Multipoint with one Point as a Point.
    WktExportPolygon Exports a MultiPolygon with one Polygon as a Polygon.
    WktExportStripMs Removes M values from the exported shape.
    WktExportStripZs Removes Z values from the exported shape.
    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
    
    Import and Export Geometries to well-known Binary
    // create a polyline
    List<Coordinate2D> coords = new List<Coordinate2D>
    {
      new Coordinate2D(0, 0),
      new Coordinate2D(0, 1),
      new Coordinate2D(1, 1),
      new Coordinate2D(1, 0)
    };
    
    Polyline polyline = PolylineBuilderEx.CreatePolyline(
                coords, SpatialReferences.WGS84);
    
    WkbExportFlags wkbExportFlags = WkbExportFlags.WkbExportDefaults;
    WkbImportFlags wkbImportFlags = WkbImportFlags.WkbImportDefaults;
    
    // export and import
    byte[] buffer = GeometryEngine.Instance.ExportToWKB(wkbExportFlags, polyline);
    Geometry geometry = GeometryEngine.Instance.ImportFromWKB(
                   wkbImportFlags, buffer, SpatialReferences.WGS84);
    Polyline importPolyline = geometry as Polyline;
    
    
    // alternatively, determine the size for the buffer
    int bufferSize = GeometryEngine.Instance.GetWKBSize(wkbExportFlags, polyline);
    buffer = new byte[bufferSize];
    // export
    bufferSize = GeometryEngine.Instance.ExportToWKB(
                    wkbExportFlags, polyline, ref buffer);
    // import
    importPolyline = GeometryEngine.Instance.ImportFromWKB(
             wkbImportFlags, buffer, SpatialReferences.WGS84) as Polyline;
    
    Inheritance Hierarchy

    System.Object
       System.ValueType
          System.Enum
             ArcGIS.Core.Geometry.WktExportFlags

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also