This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > Geometry > ESRI.ArcGIS.Geometry > Interfaces > IT > ITopologicalOperator Interface > ITopologicalOperator.Difference Method (ArcObjects .NET 10.5 SDK) |
Constructs the geometry containing points from this geometry but not the other geometry.
[Visual Basic .NET] Public Function Difference ( _ ByVal other As IGeometry _ ) As IGeometry
[C#] public IGeometry Difference ( IGeometry other );
[C++]
HRESULT Difference(
IGeometry* other,
IGeometry** resultGeom
);
[C++]
Parameters other
other is a parameter of type IGeometry resultGeom [out, retval]
resultGeom is a parameter of type IGeometry
Difference create a Geometry that is composed only of the region unique to the base geometry but not part of the input geometry.
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.
This method does not support GeometryBags.
//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