ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / ConstructPolygonsFromPolylines Method
The set of polylines to create polygons from. If a polyline has curves, a densified copy of it is used to construct the polygons.
Example

In This Topic
    ConstructPolygonsFromPolylines Method (GeometryEngine)
    In This Topic
    Generates polygons from a set of polylines.
    Syntax
    public IReadOnlyList<Polygon> ConstructPolygonsFromPolylines( 
       IEnumerable<Polyline> polylines
    )
    Public Function ConstructPolygonsFromPolylines( _
       ByVal polylines As IEnumerable(Of Polyline) _
    ) As IReadOnlyList(Of Polygon)

    Parameters

    polylines
    The set of polylines to create polygons from. If a polyline has curves, a densified copy of it is used to construct the polygons.

    Return Value

    Returns the polygons. If none are created, then the collection returned is empty.
    Exceptions
    ExceptionDescription
    The polylines is null.
    Remarks
    The polylines may cross rather than be connected from end to end.

    ConstructPolygonsFromPolylines

    Example
    Construct a Polygon from a set of Polylines
    List<Coordinate2D> firstLinePts = new List<Coordinate2D>();
    firstLinePts.Add(new Coordinate2D(1.0, 1.0));
    firstLinePts.Add(new Coordinate2D(1.0, 4.0));
    
    List<Coordinate2D> secondLinePts = new List<Coordinate2D>();
    secondLinePts.Add(new Coordinate2D(4.0, 4.0));
    secondLinePts.Add(new Coordinate2D(4.0, 1.0));
    
    List<Coordinate2D> thirdLinePts = new List<Coordinate2D>();
    thirdLinePts.Add(new Coordinate2D(0.0, 2.0));
    thirdLinePts.Add(new Coordinate2D(5.0, 2.0));
          
    List<Coordinate2D> fourthLinePts = new List<Coordinate2D>();
    fourthLinePts.Add(new Coordinate2D(0.0, 3.0));
    fourthLinePts.Add(new Coordinate2D(5.0, 3.0));
    
    // build the polylines
    List<Polyline> polylines = new List<Polyline>();
    polylines.Add(PolylineBuilderEx.CreatePolyline(firstLinePts));
    polylines.Add(PolylineBuilderEx.CreatePolyline(secondLinePts));
    polylines.Add(PolylineBuilderEx.CreatePolyline(thirdLinePts));
    polylines.Add(PolylineBuilderEx.CreatePolyline(fourthLinePts));
    
    // construct polygons from the polylines
    var polygons = GeometryEngine.Instance.ConstructPolygonsFromPolylines(polylines);
    
    // polygons.Count = 1
    // polygon coordinates are (1.0, 2.0), (1.0, 3.0), (4.0, 3.0), (4.0, 2.0)
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also