The SE_Dissolve() function

The SE_Dissolve() function is an aggregate function that computes the union of geometries of the same dimension. If just one geometry satisfies your query, it is returned unaltered.

Syntax

SE_Dissolve (g1 ST_Geometry)

Usage

The following figure shows the union of various geometric objects.
Figure 1: Geometries resulting from use of SE_Dissolve()

This graphic shows the union of various geometric objects.

Return type

ST_Geometry

Example

The following example creates a single multipolygon from the individual hexagons that are inserted into the honeycomb table:
CREATE TABLE honeycomb (cell_id int, hex_cell ST_Polygon);

INSERT INTO honeycomb 
   VALUES (1, '0 polygon((5 10,7 7,10 7,12 10,10 13,7 13,5 10))');
INSERT INTO honeycomb 
   VALUES (2, '0 polygon((12 4,15 4,17 7,15 10,12 10,10 7,12 4))');
INSERT INTO honeycomb 
   VALUES (3, '0 polygon((17 7,20 7,22 10,20 13,17 13,15 10,17 7))');
INSERT INTO honeycomb 
   VALUES (4, '0 polygon((15 10,17 13,15 16,12 16,10 13,12 10,15 10))');


SELECT SE_Dissolve(hex_cell) FROM honeycomb;

se_dissolve  0 MULTIPOLYGON (((5 10, 7 7, 10 7, 12 4, 15 4, 17 7, 20 7, 22
10, 20 13, 17 13, 15 16, 12 16, 10 13, 7 13, 5 10)))