ST_UnaryUnion — Computes the union of the components of a single geometry.
geometry ST_UnaryUnion(geometry geom, float8 gridSize = -1
A single-input variant of ST_Union. The input may be a single geometry, a MultiGeometry, or a GeometryCollection. The union is applied to the individual components of the input. This allow using this function to fix MultiPolygons which are invalid due to overlapping components. (However, the input components must each be valid. An invalid input component such as a bow-tie polygon may cause an error.)
Another use of this function is to node and dissolve a collection of linestrings. (This can also be done with ST_Node.)
It is possible to mix ST_UnaryUnion with ST_Collect to fine-tune how many geometries are be unioned at once. This allows trading off between memory usage and compute time, striking a balance between ST_Union and ST_MemUnion.
If the optional
gridSize argument is provided, the inputs are
snapped to a grid of the given size, and the result vertices are computed
on that same grid. (Requires GEOS-3.9.0 or higher)
This function supports 3d and will not drop the z-index. However, the result is computed using XY only. The result Z values are copied, averaged or interpolated.
Enhanced: 3.1.0 accept a gridSize parameter - requires GEOS >= 3.9.0