2

Does anyone know how to convert existing line geometry to polygons with arcobjects as it works with the geoprocessing tool "feature to polygon"?

2

2 Answers 2

3

The IFeatureConstruct interface has several different methods for doing this.

1
  • +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!
    – Barbarossa
    Commented Apr 20, 2021 at 20:52
0

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;

    }
2
  • It sounds like the opposite is what is being requested.
    – blah238
    Commented Apr 29, 2013 at 4:55
  • 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.
    – Yvan
    Commented May 3, 2013 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.