5

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

2 Answers 2

4

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.

1
  • Great - this is what I was searching for.
    – Radar
    Commented Jul 12, 2011 at 17:10
2

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

1

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.