This topic describes the ST_UnaryUnion function. This function aggregates a complex geometry object and returns a new geometry object.

Syntax

geometry  ST_UnaryUnion(geometry geom, float8 gridsize defalut -1.0, cstring options default '{}'); 
geometry  ST_UnaryUnion(geometry  geom , cstring  options);

Parameters

Parameter Description
geom The geometry object that you want to specify. In most cases, the geometry object is a complex geometry, a MultiGeometry, or a GeometryCollection.
gridsize The size of the grid that you want to specify. This parameter is used to merge vertices in the same grid when you perform a union operation. The default value is -1.0, which indicates that this parameter is disabled.
options The state of the parallel computing feature and the degree of parallelism that you want to specify.

The degree of parallelism ranges from 1 to 64. The value of this parameter is a JSON string, such as '{"parallel": 4}'. The example value indicates that the parallel computing feature is enabled and the degree of parallelism is 4. The default value is '{}', which indicates that the sequential computing feature is used.

Examples

select st_area(st_union(geom)) from tableA where id = 1;
select st_area(st_union(geom, 0.005)) from tableA where id = 1;
select st_area(st_union(geom, '{"parallel": 4}'::cstring)) from tableA where id = 1;