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
parameter is given (GEOS-3.9.0 or higher required),
all result vertices are guaranteed to fall on a grid of the specified
size. For the operation to give predictable results all the input vertices
must fall already on the specified grid, see ST_ReducePrecision.
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
Availability: 2.0.0