# ArcObjects - Finding the intersection of a polyline and polygon?

I have a polyline and polygon. The polyline will intersect the polygon at two or fewer points. I would like to get these intersection points as X and Y values.

EDIT: Here is a quick code sample using ITopologicalOperator based on the answers below. It's a quick chop job, but it'll help get others started.

``````        Public Function GetPolygonIntersection(ByVal pLine As IPolyline, ByVal pPolygon As IPolygon) As IPoint

Dim pGeom As IGeometry
Dim pTopo As ITopologicalOperator = pLine
Dim pPoints As IPointCollection
Dim pPoint As IPoint = Nothing

If Not pTopo.IsSimple Then pTopo.Simplify()
pGeom = pTopo.Intersect(pPolygon, esriGeometry0Dimension)
If pGeom.IsEmpty Then
Return Nothing
End If

If pGeom.GeometryType = esriGeometryMultipoint Then
pPoints = pGeom
If pPoints.PointCount = 1 Then
pPoint = pPoints.Point(0)
End If
End If

Return pPoint
End Function
``````
-

Use ITopologicalOperator.Intersect. You cast one of the geometries to this interface and call the method with the other geometry as a parameter.

You mention you want point coordinates as the result. Polygon and polyline intersection will yield points only if the polyline touches the polygon on its outline. Perhaps that's what you are after, but you can also consider getting the polygon's outline first and work with that instead.

-
Great - this is what I was searching for. – Radar Jul 12 '11 at 17:10

You can use ITopologicalOperator:

1. First cast your geometry to (IGeometry) to ITopologicalOperator

2. Use the intersect method

Check out the documentation on it. It if full of minor important details

http://resources.esri.com/help/9.3/ArcGISEngine/ArcObjects/esrigeometry/itopologicaloperator.htm

-
Here is the Arc10 link: help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… Thanks for the help! – Radar Jul 12 '11 at 17:12