0

I have a polyline feature class with several closed lines (the start point = the end point). I need to break these lines in two features, using ArcObjects (doesn't matter Java, VB or C#).

I have already detected these closed lines in this way:

IFeatureCursor featureCursor = lineFeatureClass.search(null, false);
        IFeature feature = null;
        while((feature = featureCursor.nextFeature()) != null) {
            IGeometry geometry = feature.getShape();
            IPolyline polyline = (IPolyline)geometry;
            if(polyline.isClosed()) {
                log.info("closed line detected");
                boolean[] splitHappened = new boolean[1];
                int[] newPartIndex = new int[1];
                int[] newSegmentIndex = new int[1];
                polyline.splitAtDistance(0.5, true, true, splitHappened, newPartIndex, newSegmentIndex);

            }
        }

Now, I get a polyline composed of 2 parts (or path), and I don't know how to get them.

Then, I need to remove the second path from the current feature, and create a new feature with the second path as a geometry and the same attribute values.

Does anyone know what's the best way to do that?

  • Not sure if this will help you, but there are geoprocessing tools you can call in ArcObjects to seperate multipart features into individual features: (resources.arcgis.com/en/help/main/10.1/index.html#//…) – pvdev Nov 18 '14 at 9:35
  • yes, maybe it's a good way to split polylines as multipart, and then to get singleparts with the geoprocessing tool. Nevertheless, I would prefer not to create a new feature class. – superrache Nov 18 '14 at 9:45
1

polyline.splitAtDistance doesn't actually split a polyline. All you have to do is cast your IFeature as IFeatureEdit and use the method IFeatureEdit.Split(). This will create two separate features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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