ArcObjects Library Reference (Geometry)  

ITopologicalOperator.Intersect Method

Constructs the geometry that is the set-theoretic intersection of the input geometries. Use different resultDimension values to generate results of different dimensions.

[Visual Basic .NET]
Public Function Intersect ( _
    ByVal other As IGeometry, _
    ByVal resultDimension As esriGeometryDimension _
) As IGeometry
[C#]
public IGeometry Intersect (
    IGeometry other,
    esriGeometryDimension resultDimension
);
[C++]
HRESULT Intersect(
  IGeometry* other,
  esriGeometryDimension resultDimension,
  IGeometry** intersection
);
[C++]

Parameters

other

  other is a parameter of type IGeometry

resultDimension

  resultDimension is a parameter of type esriGeometryDimension

intersection [out, retval]

  intersection is a parameter of type IGeometry

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

When two geometries of the same dimension intersect with resultDimension the same as the input geometries, the output is a geometry containing only the regions of overlap between the original geometries.

Remarks

Intersection is basically an AND between input geometries.

ITopologicalOperator methods must be applied on high-level geometries only. High-Level geometries are point, multipoint, polyline and polygon. To use this method with low-level geometries such as segments (Line, Circular Arc, Elliptic Arc, Bézier Curve), paths or rings, they must be wrapped into high-level geometries types.

Note that when esriGeometryNoDimension is specified as resultDimension, the output will be in the dimension of the minimum dimension of the input geometries.

This method does not support GeometryBags.

Since ArcGIS 9.2, Intersect has a larger cost - it takes longer to run the method.  Therefore, it is a better approach to test if the two geometries are disjoint before calling Intersect.

Intersection Example

[C#]

//The following code shows to wrap a line segment into a polyline in C#

//Assume a line (line1 as ILine) is already created

object obj = Type.Missing;

ISegmentCollection segCollection = new PolylineClass() as ISegmentCollection;

segCollection.AddSegment((ISegment)line1, ref obj, ref obj);

//Set the spatial reference on the new polyline

//The spatial reference is not transfered automatically from the segments

IGeometry geom = segCollection as IGeometry;

geom.SpatialReference = spatialRef;

//Can now be used with ITopologicalOperator methods

 

See Also

ITopologicalOperator Interface | IConstructMultipoint.ConstructIntersection Method | ITopologicalOperator.Intersect Method | IConstructMultipoint.ConstructIntersectionEx Method

.NET Samples

ViperPin tool (Code Files: ViperPinForm)

.NET Related Topics

How to create a polyline