I've got a polyline feature class and I've identified the first feature that is a multipart feature. I now want to find out which of the paths of this multipart feature intersects with a point. Up till now I managed to fill a geometry collection with the parts (paths) of the polyline. My method to check for the intersection requires a polyline input. And this is where I'm stuck. How can I convert/cast/? one of the two paths in the geometry collection to a polyline?

Here is some code, but pPolylineCSPart is null:

//right polyline into geometry collection
IGeometryCollection pGeometryCollection = new PolylineClass();
pGeometryCollection = pRightPolyline as IGeometryCollection;
//loop through geometry collection
for (int intPartCount = 0; intPartCount < pGeometryCollection.GeometryCount; intPartCount++)
    IPolyline pPolylineCSPart = new PolylineClass();
    //cast polyline part to polyline
    pPolylineCSPart = pGeometryCollection.get_Geometry(intPartCount) as IPolyline;
    //check if part intersects river
    bMultipartIntersectRiver = PolylineIntersectioCheck.Are2PolylinesIntersecting(pPoint, pPolylineCSPart);
    if (bMultipartIntersectRiver)
        pSplitFeat.Shape = pPolylineCSPart;
        SplitCSFClass.CopyAttributes(pTransectSplit, pSplitFeat);

Many Thanks!

1 Answer 1


You need to wrap individual paths into the higher-level geometries, which is a Polyline. Then you can check for intersection with another geometry.

The most reliable way to wrap a path in a polyline is to:

  1. Create a new instance of Polyline
  2. Cast the original Path as ISegmentCollection
  3. Cast the new Polyline as ISegmentCollection
  4. Add the path's segments to the polyline using ISegmentCollection.AddSegmentCollection

Depending on you scenario you may need to clone the geometries first (see IClone) to create a proper copy.

UPDATE: Not sure why I didn't realize it while writing the above, but as described in the comment, just adding the path (or its clone) to the newly created polyline of course does the trick as well, and is a lot more straightforward.

  • Thanks Petr! I had some success in the meanwhile: 1) creating a new instance of a polyline; 2) casting the path in the geometry collection to IPath; 3) casting the new instance of a polyline to a new geometry collection; 4) add the path as geometry to the geometry collection; I would post it as code here but I can't figure out how it works in comments. Anyway, thanks for your solution, I consider it as answered.
    – Hubert
    Commented May 14, 2013 at 13:52

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.