Fork me on GitHub

ST_Difference

Signatures

GEOMETRY ST_Difference(GEOMETRY geomA, GEOMETRY geomB)

Description

Computes the difference between geomA and geomB.

Implements the OpenGIS Simple Features Implementation Specification for SQL version 1.2.1.

Examples

geomA Polygon geomB Polygon
POLYGON((1 1, 7 1, 7 6, 1 6, 1 1)) POLYGON((3 2, 8 2, 8 8, 3 8, 3 2))
SELECT ST_Difference(geomA, geomB) FROM input_table;
-- Answer:    POLYGON((1 1, 7 1, 7 2, 3 2, 3 6, 1 6, 1 1))

SELECT ST_Difference(geomB, geomA) FROM input_table;
-- Answer:    POLYGON((7 2, 8 2, 8 8, 3 8, 3 6, 7 6, 7 2))

See also