> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ST_Union

Variant 1: Return the union of geometry A and B.

Variant 2 : As of version `1.6.0`, this function accepts an array of Geometry objects and returns the geometric union of all geometries in the input array. If the polygons within the input array do not share common boundaries, the ST\_Union result will be a MultiPolygon geometry.

<img src="https://mintcdn.com/wherobots/wLm_IRUSNlHZTHJP/images/sql-functions/ST_Union/ST_Union.svg?fit=max&auto=format&n=wLm_IRUSNlHZTHJP&q=85&s=a3d5b72cca5c81adf3760462c4c697bd" alt="ST_Union" width="500" height="300" data-path="images/sql-functions/ST_Union/ST_Union.svg" />

## Signatures

```sql theme={"system"}
ST_Union (A: Geometry, B: Geometry)
```

```sql theme={"system"}
ST_Union (geoms: Array(Geometry))
```

## Parameters

<ParamField body="A" type="Geometry">
  The input geometry.
</ParamField>

<ParamField body="B" type="Geometry">
  The second geometry.
</ParamField>

<ParamField body="geoms" type="Array<Geometry>">
  An array of geometry objects to union.
</ParamField>

## Return type

<ResponseField type="Geometry">
  The resulting geometry.
</ResponseField>

## Examples

```sql theme={"system"}
SELECT ST_Union(ST_GeomFromWKT('POLYGON ((-3 -3, 3 -3, 3 3, -3 3, -3 -3))'), ST_GeomFromWKT('POLYGON ((1 -2, 5 0, 1 2, 1 -2))'))
```

```
POLYGON ((3 -1, 3 -3, -3 -3, -3 3, 3 3, 3 1, 5 0, 3 -1))
```

```sql theme={"system"}
SELECT ST_Union(
    Array(
        ST_GeomFromWKT('POLYGON ((-3 -3, 3 -3, 3 3, -3 3, -3 -3))'),
        ST_GeomFromWKT('POLYGON ((-2 1, 2 1, 2 4, -2 4, -2 1))')
    )
)
```

```
POLYGON ((2 3, 3 3, 3 -3, -3 -3, -3 3, -2 3, -2 4, 2 4, 2 3))
```
