ConstructPolygonsFromPolylines Method (IGeometryEngine)
Generates polygons from a set of polylines.
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.
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)
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.