ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / Union Method / Union(IEnumerable<Geometry>) Method
The collection of geometries to union.
Example

In This Topic
    Union(IEnumerable<Geometry>) Method
    In This Topic
    Constructs the set-theoretic union of the input geometries.
    Syntax

    Parameters

    geometries
    The collection of geometries to union.

    Return Value

    A geometry representing the union of the input geometries.
    Exceptions
    ExceptionDescription
    Geometries is null or empty.
    The method is not implemented for GeometryBag.
    Geometry is the wrong type for this operation. Cannot union different geometry types.
    Incompatible spatial references between the input geometries.
    One of the geometries has a spatial reference which is an image coordinate system.
    Remarks
    An exception is thrown if the SpatialReferences of the geometries are not equal or if the geometry types are not equal. However, points and multipoints are considered to be the same type.

    GeometryEngine Union

    Example
    Union many Polylines
    // union many polylines
    
    List<Coordinate2D> coords = new List<Coordinate2D>()
    {
      new Coordinate2D(1, 2), new Coordinate2D(3, 4), new Coordinate2D(4, 2),
      new Coordinate2D(5, 6), new Coordinate2D(7, 8), new Coordinate2D(8, 4),
      new Coordinate2D(9, 10), new Coordinate2D(11, 12), new Coordinate2D(12, 8),
      new Coordinate2D(10, 8), new Coordinate2D(12, 12), new Coordinate2D(14, 10)
    };
    
    // create Disjoint lines
    List<Polyline> manyLines = new List<Polyline>
    {
      PolylineBuilderEx.CreatePolyline(new List<Coordinate2D>(){coords[0], coords[1], coords[2]}, SpatialReferences.WGS84),
      PolylineBuilderEx.CreatePolyline(new List<Coordinate2D>(){coords[3], coords[4], coords[5]}),
      PolylineBuilderEx.CreatePolyline(new List<Coordinate2D>(){coords[6], coords[7], coords[8]})
    };
    
    Polyline polyline = GeometryEngine.Instance.Union(manyLines) as Polyline;
    Union many Polygons
    // union many polygons
    
    List<Coordinate3D> coordsZ = new List<Coordinate3D>()
    {
      new Coordinate3D(1, 2, 0), new Coordinate3D(3, 4, 1), new Coordinate3D(4, 2, 2),
      new Coordinate3D(5, 6, 3), new Coordinate3D(7, 8, 4), new Coordinate3D(8, 4, 5),
      new Coordinate3D(9, 10, 6), new Coordinate3D(11, 12, 7), new Coordinate3D(12, 8, 8),
      new Coordinate3D(10, 8, 9), new Coordinate3D(12, 12, 10), new Coordinate3D(14, 10, 11)
    };
    
    // create polygons
    List<Polygon> manyPolygonsZ = new List<Polygon>
    {
      PolygonBuilderEx.CreatePolygon(new List<Coordinate3D>(){coordsZ[0], coordsZ[1], coordsZ[2]}, SpatialReferences.WGS84),
      PolygonBuilderEx.CreatePolygon(new List<Coordinate3D>(){coordsZ[3], coordsZ[4], coordsZ[5]}),
      PolygonBuilderEx.CreatePolygon(new List<Coordinate3D>(){coordsZ[6], coordsZ[7], coordsZ[8]})
    };
    
    Polygon polygon = GeometryEngine.Instance.Union(manyPolygonsZ) as Polygon;
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also