If I have a polyline, how do I figure out whether it is self-intersecting? I tried to use ITopologicalOperator.IsSimple Property, but it always returns true.

Are there any ways of doing these kind of topological checks over individual geometries?

  • As a last resort you can split polyline into segments, and check intersection between each segment, but this should be done only if there is no other way to do that, because it most likely will be quite slow.
    – Sunder
    Commented Nov 20, 2012 at 10:44

2 Answers 2


I think you can do with with the ITopologicalOperator2 interface:

dim pTopoLogicalOp as ITopologicalOperator2
Set pPolyline = pFeature.ShapeCopy
Set pTopoLogicalOp = pPolyline
Let pTopoLogicalOp.IsKnownSimple = False
If pTopoLogicalOp.IsSimple = False Then
   ' Polyline is self intersecting
End If
  • doesn't work. pTopoLogicalOp.IsSimple is always true Commented Nov 20, 2012 at 10:57
  • I played around a little bit more, and found that your code works in VBA, but the corresponding code in C# still gives IsSimple as true. There are also quite a few issues mentioned with ITopologicalOperator, so we'll have to chalk it down to that. Commented Nov 20, 2012 at 11:38

The Polyline should be converted to a Polygon, and then the ITopologicalOperator3:get_IsSimpleEx() method can be used

Here is the sample code

private bool IsLineSelfIntersecting(IPolyline line)
        bool isSelfIntersecting = false;

        IPointCollection polygonVertices = new PolygonClass();
        IPointCollection lineVertices = line as IPointCollection;

        polygonVertices.AddPointCollection(lineVertices); //convert to Polygon

        ITopologicalOperator3 topo = polygonVertices as ITopologicalOperator3;
        esriNonSimpleReasonEnum reason =esriNonSimpleReasonEnum.esriNonSimpleSelfIntersections;
        topo.IsKnownSimple_2 = false;
        if (!topo.get_IsSimpleEx(out reason))
            if (reason == esriNonSimpleReasonEnum.esriNonSimpleSelfIntersections)
                isSelfIntersecting = true;

        return isSelfIntersecting;

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.