ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.Geometry Namespace / PolygonBuilderEx Class / CreatePolygon Method / CreatePolygon(PolygonBuilderEx,SpatialReference) Method
The builder to create the polygon.
(Optional) The SpatialReference. The default value is null. If the input spatial reference is null, then the spatial reference from the input builder is used.
Example

In This Topic
    CreatePolygon(PolygonBuilderEx,SpatialReference) Method
    In This Topic
    Convenience method to create a new instance of the Polygon class.
    Syntax
    Public Overloads Shared Function CreatePolygon( _
       ByVal polygonBuilderEx As PolygonBuilderEx, _
       Optional ByVal spatialReference As SpatialReference _
    ) As Polygon

    Parameters

    polygonBuilderEx
    The builder to create the polygon.
    spatialReference
    (Optional) The SpatialReference. The default value is null. If the input spatial reference is null, then the spatial reference from the input builder is used.
    Exceptions
    ExceptionDescription
    polygonBuilderEx is null.
    Example
    Get the individual parts of a multipart feature
    IEnumerable<Geometry> MultipartToSinglePart(Geometry inputGeometry)
    {
      // list holding the part(s) of the input geometry
      List<Geometry> singleParts = new List<Geometry>();
    
      // check if the input is a null pointer or if the geometry is empty
      if (inputGeometry == null || inputGeometry.IsEmpty)
      {
        return singleParts;
      }
    
      // based on the type of geometry, take the parts/points and add them individually into a list
      switch (inputGeometry.GeometryType)
      {
        case GeometryType.Envelope:
          singleParts.Add(inputGeometry.Clone() as Envelope);
          break;
        case GeometryType.Multipatch:
          singleParts.Add(inputGeometry.Clone() as Multipatch);
          break;
        case GeometryType.Multipoint:
          var multiPoint = inputGeometry as Multipoint;
    
          foreach (var point in multiPoint.Points)
          {
            // add each point of collection as a standalone point into the list
            singleParts.Add(point);
          }
          break;
        case GeometryType.Point:
          singleParts.Add(inputGeometry.Clone() as MapPoint);
          break;
        case GeometryType.Polygon:
          var polygonNew = inputGeometry as Polygon;
    
          foreach (var polygonPart in polygonNew.Parts)
          {
            // use the PolygonBuilderEx turning the segments into a standalone
            // polygon instance
            singleParts.Add(PolygonBuilderEx.CreatePolygon(polygonPart));
          }
          break;
        case GeometryType.Polyline:
          var polylineNew = inputGeometry as Polyline;
    
          foreach (var polylinePart in polyline.Parts)
          {
            // use the PolylineBuilderEx turning the segments into a standalone
            // polyline instance
            singleParts.Add(PolylineBuilderEx.CreatePolyline(polylinePart));
          }
          break;
        case GeometryType.Unknown:
          break;
        default:
          break;
      }
      return singleParts;
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also