Does anyone know how to convert existing line geometry to polygons with arcobjects as it works with the geoprocessing tool "feature to polygon"?
2 Answers
The IFeatureConstruct interface has several different methods for doing this.
-
+1 This should be the accepted answer. Just feed the IFeatureConstruction a GeometryBag of Polyline objects, and set the ClusterTolerance really low (i.e. 0.01 if in feet). Thanks again @KirkKuykendall! Commented Apr 20, 2021 at 20:52
Here is a function I use:
public static IPolyline6 PolygonToPolyline(IPolygon4 inPolygon) {
ISegmentCollection outPolyline = new PolylineClass() as ISegmentCollection;
try {
outPolyline.AddSegmentCollection(inPolygon as ISegmentCollection);
// Mirror spatial reference of input
IPolyline6 outPolyline_ = outPolyline as IPolyline6;
outPolyline_.SpatialReference = inPolygon.SpatialReference;
} catch (Exception ex) {
Program.Log.Error(string.Format("Util::PolygonToPolyline - {0}", ex.Message));
Program.Log.Error(ex.ToString());
}
return outPolyline as IPolyline6;
}
-
-
Thank you very much for this reply. But I think this is to transform polygon to polyline and I happen to want the opposite solution which is to transform lines to polygon.– YvanCommented May 3, 2013 at 21:31