ArcGIS Pro 2.7 API Reference Guide
ConstructPolygonsFromPolylines Method (GeometryEngine)
Example 

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.
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
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(PolylineBuilder.CreatePolyline(firstLinePts));
polylines.Add(PolylineBuilder.CreatePolyline(secondLinePts));
polylines.Add(PolylineBuilder.CreatePolyline(thirdLinePts));
polylines.Add(PolylineBuilder.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 10, Windows 8.1

See Also

Reference

GeometryEngine Class
GeometryEngine Members