ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / Union Method / Union(Geometry,Geometry) Method
The first geometry to union with.
The second geometry to union with.
Example

In This Topic
    Union(Geometry,Geometry) Method
    In This Topic
    Constructs the set-theoretic union of the input geometries.
    Syntax
    Public Overloads Function Union( _
       ByVal geometry1 As Geometry, _
       ByVal geometry2 As Geometry _
    ) As Geometry

    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.
    Exceptions
    ExceptionDescription
    Either geometry1 or geometry2 or both are null.
    The method is not implemented for GeometryBag.
    Incompatible spatial references between the input geometries.
    Input geometries do not have the same dimension.
    Spatial reference of geometry1or geometry2is an image coordinate system.
    Remarks
    GeometryEngine Union

    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.

    Example
    Union two MapPoints - creates a Multipoint
    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
    // 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;
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also