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

# ST_Union

> Returns the union of two native planar polygons or multipolygons.

Returns the combined area of both inputs. Shared internal boundaries are removed, and disjoint components are preserved.

## Syntax

```sql theme={null}
GEOMETRY ST_Union(GEOMETRY lhs, GEOMETRY rhs)
```

## Behavior and limits

Both arguments must be native XY `POLYGON` or `MULTIPOLYGON` values with compatible CRS descriptors. All four polygon/multipolygon combinations are supported. The return type is native `GEOMETRY` with the same CRS and XY coordinates: one area component is a `POLYGON`, multiple components are a `MULTIPOLYGON`, and an empty result is `POLYGON EMPTY`.

`NULL` propagates. `EMPTY` is an empty area, not `NULL`. Non-NULL inputs are checked for structural and topological validity, including holes and relationships between multipolygon components, before applying empty-input behavior. Invalid inputs produce errors; they are not repaired.

These are Cartesian operations even for EPSG:4326 (straight edges in degrees). EPSG:3857 uses projected coordinates in metres. Coordinates are never implicitly transformed. `GEOGRAPHY`, points, lines, collections, Z/M coordinates, incompatible CRS descriptors, aggregate/array forms and precision-grid arguments are unsupported.

Calculations use floating-point arithmetic without snapping or integer rescaling. WKB output uses double coordinates. Ring orientation, start vertex and component order can change. If translating an operand to the common local origin or rounding the output loses topology, the function reports an error instead of repairing or dropping geometry.

Each input is limited to 256 KiB WKB and 5,000 coordinates, including ring-closing coordinates. For counts `n` and `m`, the function also requires `n*n + m*m + n*m <= 25,000,000`. Output and each symmetric-difference intermediate are limited to 5,000 coordinates; the intermediate pair also obeys the same work bound. Exceeding a limit produces an error, without truncation. Query memory limits apply to the input models and temporary allocations. Cancellation is checked between rows and around overlay calls; a single Boost call has no cancellation callback. These bounds are not a fixed peak-memory or wall-clock guarantee.

## Examples

```SQL theme={null}
SELECT ST_Area(ST_Union(
    ST_GeomFromText('POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))', 'EPSG:3857'),
    ST_GeomFromText('POLYGON ((2 0, 6 0, 6 4, 2 4, 2 0))', 'EPSG:3857')));
-- 24

SELECT ST_AsText(ST_Union(
    ST_GeomFromText('POLYGON EMPTY', 'EPSG:3857'),
    ST_GeomFromText('POLYGON EMPTY', 'EPSG:3857')));
-- POLYGON EMPTY
```

## Related data types

[GEOMETRY](/documents/4.2/sql-reference/data-types/spatial-types/GEOMETRY.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.