ST_Difference — Returns a geometry that represents the point set difference of a Geometry with another Geometry.
geometry ST_Difference(
bytea GeomA, bytea GeomB)
;
Returns a geometry that represents the point set difference of a Geometry with another Geometry. This method returns the closure of the resultant Geometry.
GeometryCollections are unsupported. |
2D | 3D | M |
---|---|---|
OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
---|---|---|---|
2.1.1.3 | 7.2.21.1 | 7.2.8.1 | 5.1.20 |
SELECT ST_AsEWKT(ST_Difference(A,B)) from (SELECT ST_GeomFromText('POLYGON ((40 20, 40 100, 120 100, 120 20, 40 20))',25830) as A, ST_GeomFromText('POLYGON ((80 60, 80 130, 170 130, 170 60, 80 60))',25830) as B) as foo; --Result SRID=25830;POLYGON ((40 20, 40 100, 80 100, 80 60, 120 60, 120 20, 40 20))
ST_Difference (A,B) | ST_Difference (B,A) |