Show / Hide Table of Contents

Method Difference

Difference(Geometry, Geometry)

Constructs the set-theoretic difference between two geometries.

Declaration
public static Geometry Difference(this Geometry geometry1, Geometry geometry2)
Parameters
Type Name Description
Geometry geometry1

is the Geometry instance on the left hand side of the subtraction.

Geometry geometry2

is the Geometry on the right hand side being subtracted.

Returns
Type Description
Geometry

Returns the result of subtraction. The result has the dimension of the geometry1. If given geometries are identical, returns empty geometry.

Remarks

The GeometryEngine.Difference method performs a spatial subtraction from the two input geometries. This means that the order of the two input geometry arguments of the GeometryEngine.Difference Static Method will have different results if they are switched. In a theoretical variable format you can think of the GeometryEngine.Difference equation like:
A (Difference) B = C
B (Difference) A = D

If you were looking for the "symmetric" difference between two geometries you will need to run the GeometryEngine.Difference twice by switching the order of the input arguments and then add the two resultant geometries together (most likely via the GeometryEngine.Union Static Method). This "symmetric" difference means that you would be interested in obtaining those parts of the two input geometries that do not overlap. In a theoretical variable format to get the "symmetric" different between two geometries you can think of the GeometryEngine.Difference equation like:
[A (Difference) B] + [B (Difference) A] = Symmetric Difference

If you desire not to compute the "symmetric" difference using the step-by-step process just described, you could use the SymmetricDifference(Geometry, Geometry) method instead.

The following is a visual illustration of two polygon geometries and how the output result would be from the GeometryEngine.Difference operation:

GeometryEngine.Difference visual examples.

Supports true curves.

See Also
SymmetricDifference(Geometry, Geometry)

Applies to

Platforms and versions
TargetVersions
.NET Standard 2.0100.3 - 200.7
.NET100.13 - 200.7
.NET Windows100.13 - 200.7
.NET Android200.0 - 200.7
.NET iOS200.0 - 200.7
.NET Framework100.0 - 200.7
Xamarin.Android100.0 - 100.15
Xamarin.iOS100.0 - 100.15
UWP100.0 - 200.7
In This Article
Back to top Copyright © 2022 Esri.