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

# ST_CoverageSimplify

> Jointly simplifies a window partition of native planar polygons while preserving coverage topology.

Jointly simplifies an entire window partition of edge-matched native Cartesian XY polygons. Shared edges are simplified together, so adjacent rows retain the same boundary. Each output stays with its original row and CRS. This differs from the scalar [ST\_SimplifyPreserveTopology](/documents/4.2/sql-reference/sql-functions/spatial-functions/st_simplifypreservetopology.md), which processes each geometry independently.

## Syntax

```sql theme={null}
GEOMETRY ST_CoverageSimplify(GEOMETRY geom, DOUBLE tolerance)
    OVER (PARTITION BY coverage_id)
GEOMETRY ST_CoverageSimplify(GEOMETRY geom, DOUBLE tolerance, BOOLEAN simplify_boundary)
    OVER (PARTITION BY coverage_id)
```

`OVER ()` treats all input rows as one partition. The whole partition is processed across chunk boundaries. `ORDER BY` inside `OVER`, explicit window frames, DISTINCT, IGNORE NULLS, RESPECT NULLS and analytic execution hints are unsupported. An outer query `ORDER BY` is allowed. There are no scalar, array or ordinary aggregate overloads.

## Parameters and input

`tolerance` and `simplify_boundary` must be foldable plan constants. Tolerance must be finite and nonnegative, and its square must be representable as a finite DOUBLE. The two-argument form defaults to `simplify_boundary = true`; an explicit NULL does not use the default.

Tolerance is an area-based Visvalingam–Whyatt parameter related to the square root of effective triangle area, in input coordinate units. EPSG:4326 uses Cartesian degrees and EPSG:3857 uses projected metres, not geodesic ground distance. No reprojection, snapping or coordinate clamping is performed. This is not a Hausdorff or maximum-distance guarantee and does not promise unchanged area, maximal vertex reduction or identical PostGIS output.

With `true`, both shared and exterior boundaries may simplify. With `false`, only shared internal edges simplify; exterior boundaries, gaps and unfilled hole boundaries retain their original edges. A hole filled by another coverage member is a shared internal boundary.

Inputs must be POLYGON or MULTIPOLYGON with the same planar GEOMETRY CRS descriptor. Nonempty polygon interiors must not overlap, and shared edges must have matching vertices. Gaps are allowed (`gapWidth = 0`). The function does not check that the input is a valid coverage. For invalid input, the output may contain artifacts and is not guaranteed to be a valid coverage. No repair, union or automatic noding is performed. GEOGRAPHY, POINT, LINESTRING, GEOMETRYCOLLECTION and Z/M are unsupported. UNKNOWN/MIXED storage dimension metadata is accepted only when the actual computed values pass XY validation.

## Result and errors

Returns native XY WKB GEOMETRY with the input CRS and one output per input row. For valid coverages, POLYGON/MULTIPOLYGON family, component order, holes, ring winding, contacts, junctions and shared boundaries are preserved. A single-member MULTIPOLYGON remains MULTIPOLYGON. Row mapping is positional; identical inputs are not deduplicated.

* NULL geometry returns NULL at its original position and is excluded from the coverage.
* Typed POLYGON/MULTIPOLYGON EMPTY preserves its family and position.
* NULL tolerance or explicit NULL boundary returns NULL for every row without running the coverage kernel. Type and plan-constant checks still apply.
* Zero tolerance retains structural input checks and returns the original WKB bytes, including repeated closing coordinates.
* Invalid parameters are rejected even for all-NULL/all-EMPTY or empty input. Malformed WKB, structurally invalid rings, unsupported descriptors/dimensions and exceeded limits fail the partition before its output is published.

## Resource management

The window operator and coverage kernel use the database query memory accounting and the query memory limit. Cancellation and memory checks run during input admission, kernel loops and output. Native WKB structural bounds and integer-range checks still apply. Errors do not publish partial partition results. No fixed cancellation latency or execution time is promised.

## Examples

```SQL theme={null}
WITH districts AS (
    SELECT 1 AS district_id, 7 AS coverage_id,
           'POLYGON ((0 0,0 8,4 8,4.1 6,3.8 4,4.2 2,4 0,0 0))' AS wkt
    UNION ALL
    SELECT 2, 7, 'POLYGON ((4 0,4.2 2,3.8 4,4.1 6,4 8,8 8,8 0,4 0))'
)
SELECT district_id,
       ST_AsText(ST_CoverageSimplify(ST_GeomFromText(wkt, 'EPSG:3857'), 1, false)
                 OVER (PARTITION BY coverage_id)) AS simplified
FROM districts ORDER BY district_id;
-- 1  POLYGON ((0 0, 0 8, 4 8, 4 0, 0 0))
-- 2  POLYGON ((4 0, 4 8, 8 8, 8 0, 4 0))

SELECT ST_AsText(ST_CoverageSimplify(
    ST_GeomFromText('MULTIPOLYGON EMPTY', 'EPSG:4326'), 1) OVER ());
-- MULTIPOLYGON EMPTY

SELECT ST_AsText(ST_CoverageSimplify(
    ST_GeomFromText('POLYGON EMPTY', 'EPSG:3857'), 0, NULL) OVER ());
-- NULL
```

## Related data types

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


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