ST_Intersection

Create a geometry that is the intersection of a table of geometries.

All coordinate systems are treated as being Cartesian.w

Syntax

ST_Intersection(geo);
ST_Intersection(geo1,geo2);
geo
A table column of type VARCHAR(ANY) containing geometries.
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 shared geometry. If no points are shared, the geometry is empty.

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_Intersection(the_geom)) from (SELECT the_geom from
            points order by PointID LIMIT 9999999) points;

ST_ASTEXT
---------
GEOMETRYCOLLECTION EMPTY
(1 row)
SELECT inza..ST_AsText(inza..ST_Intersection(inza..ST_WKTToSQL('
            POLYGON ((0 0, 11 0, 11 11, 0 11, 0 0))'), inza..ST_WKTToSQL('
            POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))')));

ST_ASTEXT
---------
POLYGON ((10 11, 11 11, 11 10.5, 10 10, 10 11))
(1 row)
SELECT inza..ST_AsText(inza..ST_Intersection(inza..ST_WKTToSQL('
            POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))'), inza..ST_WKTToSQL('
            POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))')));

ST_ASTEXT
-----------
GEOMETRYCOLLECTION EMPTY
(1 row)
SELECT inza..ST_AsText(inza..ST_Intersection(inza..ST_WKTToSQL('
            POLYGON ((0 0, 0 15, 15 15, 15 0, 0 0))'), inza..ST_WKTToSQL('
            POLYGON ((10 10, 10 20, 20 20, 20 15, 10 10))')));

ST_ASTEXT
-----------
POLYGON ((10 15, 15 15, 15 12.5, 10 10, 10 15))
(1 row)