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. |
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. |
System.NotImplementedException | Spatial reference of geometry1or geometry2is an image coordinate system. |
If the input geometries are not known-simple, then the operation will be performed on simplified copies of the geometries. There is no need for you to call any simplify method.
If an input geometry is an envelope, then it will be converted to a polygon. If you want the union of two envelopes to be an envelope, then use Envelope.Union.
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