Name

ST_SymDifference — Returns a Geometry object that represents the point set symmetric difference of two Geometry objects.

Synopsis

geometry ST_SymDifference(bytea GeomA, bytea GeomB);

Alias

SymDifference

Description

Returns a Geometry object that represents the point set symmetric difference of two Geometry objects. The symmetric difference is a set combining the points in both Geometries that do not intersect.

[Note]

This method does not support GeometryCollections

Coordinate Dimensions
2D3DM
Spatial Standards Support
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.37.2.21.17.2.8.15.1.21

Examples

SELECT ST_AsEWKT(ST_SymDifference(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;MULTIPOLYGON (((40 20, 40 100, 80 100, 80 60, 120 60, 120 20, 40 20)),((120 60, 120 100, 80 100, 80 130, 170 130, 170 60, 120 60)))

A,B

ST_SymDifference (A,B)

Related functions

ST_Difference,ST_Intersection