Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
Great - this is what I was searching for. –  Nick Ochoski 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

share|improve this answer
    
Here is the Arc10 link: help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/… Thanks for the help! –  Nick Ochoski Jul 12 '11 at 17:12

Your Answer

 
discard

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.