Parameters
- geometry1
- the Geometry instance on the left hand side of the subtraction.
- geometry2
- the Geometry on the right hand side being subtracted.
Return Value
Returns the result of subtraction. The result has the dimension of geometry1.
Exception | Description |
---|---|
System.ArgumentNullException | Either geometry1 or geometry2 or both are null or empty. |
System.NotImplementedException | The method is not implemented for GeometryBag. |
System.InvalidOperationException | Incompatible spatial references between the input geometries. |
List<MapPoint> polyPts = new List<MapPoint>(); polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 2.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(3.0, 6.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 6.0)); polyPts.Add(MapPointBuilder.CreateMapPoint(6.0, 2.0)); Polygon poly1 = PolygonBuilder.CreatePolygon(polyPts); Envelope env = EnvelopeBuilder.CreateEnvelope(MapPointBuilder.CreateMapPoint(1.0, 1.0), MapPointBuilder.CreateMapPoint(4, 4)); Polygon poly2 = PolygonBuilder.CreatePolygon(env); Geometry result = GeometryEngine.Instance.Difference(poly1, poly2); Polygon polyResult = result as Polygon; // polyResult.Area = 10.0 result = GeometryEngine.Instance.Difference(poly2, poly1); polyResult = result as Polygon; // polyResult.Area = 7.0
Target Platforms: Windows 10, Windows 8.1