ST_Union
Create a geometry that is the union of a the input geometries.
Syntax
ST_Union(geo);
ST_Union(geo1,geo2);
- geo
- The input geometry.
Type: VARCHAR(ANY)
- geo1
- The first input geometry.
Type: VARCHAR(ANY)
- geo2
- The second input geometry.
Type: VARCHAR(ANY)
Returns
A value of type VARCHAR(ANY) that contains the unified geometry.
Examples
CREATE TABLE points (PointID integer, the_geom VARCHAR(200));
INSERT INTO points VALUES (1, inza..ST_WKTToSQL('Point (0 0)'));
INSERT INTO points VALUES (2, inza..ST_WKTToSQL('Point (22 0)'));
INSERT INTO points VALUES (3, inza..ST_WKTToSQL('Point (33 33)'));
INSERT INTO points VALUES (4, inza..ST_WKTToSQL('Point (44 44)'));
SELECT inza..ST_AsText(inza..ST_Union(the_geom)) from (SELECT the_geom from points
order by PointID LIMIT 9999999) points;
ST_ASTEXT
-----------------------------------------
MULTIPOINT (44 44, 33 33, 22 0, 0 0)
(1 row)
SELECT inza..ST_AsText(inza..ST_Union(inza..ST_WKTToSQL('POLYGON ((0 0, 5 0, 5 5, 0 5, 0
0))'), inza..ST_WKTToSQL('POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))')));
ST_ASTEXT
-----------
MULTIPOLYGON (((0 0, 5 0, 5 5, 0 5, 0 0)), ((10 10, 10 20, 20 20, 20 15, 10 10)))
(1 row)