Parameters
- geometry1
- The first geometry to union with.
- geometry2
- The second geometry to union with.
Return Value
A geometry representing the union of the input geometries.
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. |
ArcGIS.Core.Geometry.Exceptions.InvalidParameterException | Input geometries do not have the same dimension. |
ArcGIS.Core.Geometry.Exceptions.GeometryObjectException | The operation cannot be performed on a non-simple geometry. |
System.NotImplementedException | Spatial reference of geometry1or geometry2is an image coordinate system. |
MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1.0, 1.0); MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2.0, 2.5); Geometry geometry = GeometryEngine.Instance.Union(pt1, pt2); Multipoint multipoint = geometry as Multipoint; // multipoint has point count of 2
// union two polygons List<MapPoint> polyPts = new List<MapPoint>(); polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 2.0)); polyPts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 6.0)); polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 6.0)); polyPts.Add(MapPointBuilderEx.CreateMapPoint(6.0, 2.0)); Polygon poly1 = PolygonBuilderEx.CreatePolygon(polyPts); bool isSimple = GeometryEngine.Instance.IsSimpleAsFeature(poly1); Envelope env = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(4.0, 4.0), MapPointBuilderEx.CreateMapPoint(8, 8)); Polygon poly2 = PolygonBuilderEx.CreatePolygon(env); isSimple = GeometryEngine.Instance.IsSimpleAsFeature(poly2); Geometry g = GeometryEngine.Instance.Union(poly1, poly2); Polygon polyResult = g as Polygon;
Target Platforms: Windows 11, Windows 10, Windows 8.1