Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two polylines and would like to find the intersection(s) using ArcObjects / VB.NET.

I'm using the following code:

Dim topoOp As ITopologicalOperator = TryCast(pTestPoly2, ITopologicalOperator)
topoOp.Intersect(TryCast(pTestPoly1, IGeometry), ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry0Dimension)
Dim pOutPointCol As IPointCollection = TryCast(topoOp, IPointCollection)

In the resulting IPointCollection I get all the vertices of the input pTestPoly2, although there should be one intersection of the two polylines.

What's wrong with this approach?

share|improve this question
up vote 7 down vote accepted

Use the return value of the Intersect method instead of the TopologicalOperator. Try the following instead (I use C#, not VB.NET, so hopefully this works. The casting business is really confusing):

Dim topoOp As ITopologicalOperator = TryCast(pTestPoly2, ITopologicalOperator)
Dim pOutPointCol As IPointCollection = TryCast(topoOp.Intersect(TryCast(pTestPoly1, IGeometry), ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry0Dimension), IPointCollection)
share|improve this answer
+1 Also it is common practice to make sure both geometries have spatial reference and have been simplified (via ITopologicalOperator.Simplify). – Kirk Kuykendall Nov 16 '11 at 3:52
Thanks, it works great! It is a bit confusing, though. Thanks Kirk for extra hints. – jan_b Nov 16 '11 at 6:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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