ArcGIS Server Banner

ST_SymmetricDiff

ST_SymmetricDiff

Release 9.3 E-mail This TopicPrintable VersionGive Us feedback
Note: This topic was updated for 9.3.1.

Definition

ST_SymmetricDiff takes two geometry objects and returns a geometry object that is composed of the parts of the source objects that are not common to both.

Syntax

Oracle

sde.st_symmetricdiff (g1 sde.st_geometry, g2 sde.st_geometry)

PostgreSQL

st_symmetricdiff (g1 st_geometry, g2 st_geometry)

Return type

ST_Geometry

Example

For a special report, the county supervisor must determine the sensitive areas and hazardous site radii areas that aren't intersected.

The sensitive_areas table contains several columns that describe the threatened institutions in addition to the zone column, which stores the institutions' ST_Polygon geometries.

The hazardous_sites table stores the identity of the sites in the site_id and name columns, while the actual geographic location of each site is stored in the location point column.

Oracle

CREATE TABLE sensitive_areas (id integer, 
                               zone sde.st_geometry); 

CREATE TABLE hazardous_sites (id integer, 
                              location sde.st_geometry); 

INSERT INTO sensitive_areas VALUES (
1,
sde.st_polygon ('polygon ((20 30, 30 30, 30 40, 20 40, 20 30))', 0)
);

INSERT INTO sensitive_areas VALUES (
2,
sde.st_polygon ('polygon ((30 30, 30 50, 50 50, 50 30, 30 30))', 0)
);

INSERT INTO sensitive_areas VALUES (
3,
sde.st_polygon ('polygon ((40 40, 40 60, 60 60, 60 40, 40 40))', 0)
);

INSERT INTO hazardous_sites VALUES (
4,
sde.st_point ('point (60 60)', 0)
);

INSERT INTO hazardous_sites VALUES (
5,
sde.st_point ('point (30 30)', 0)
);

PostgreSQL

CREATE TABLE sensitive_areas (id integer, 
                               zone st_geometry); 

CREATE TABLE hazardous_sites (id integer, 
                              location st_geometry); 

INSERT INTO sensitive_areas VALUES (
1,
st_polygon ('polygon ((20 30, 30 30, 30 40, 20 40, 20 30))', 0)
);

INSERT INTO sensitive_areas VALUES (
2,
st_polygon ('polygon ((30 30, 30 50, 50 50, 50 30, 30 30))', 0)
);

INSERT INTO sensitive_areas VALUES (
3,
st_polygon ('polygon ((40 40, 40 60, 60 60, 60 40, 40 40))', 0)
);

INSERT INTO hazardous_sites VALUES (
4,
st_point ('point (60 60)', 0)
);

INSERT INTO hazardous_sites VALUES (
5,
st_point ('point (30 30)', 0)
);

The ST_Buffer function generates a buffer surrounding the hazardous waste site locations. The ST_SymmetricDiff function returns the polygons of the buffered hazardous waste sites and the sensitive areas that don't intersect.

Oracle

SELECT sa.id SA_ID,hs.id HS_ID,
sde.st_area (sde.st_symmetricdiff (sde.st_buffer (hs.location, .1), sa.zone)) AREA_NO_INT
FROM hazardous_sites hs, sensitive_areas sa
WHERE hs.id = 4;

     SA_ID    HS_ID   AREA_NO_INT

         1        4    100.031393
         2        4    400.031393
         3        4    400.015697

PostgreSQL

SELECT sa.id AS SA_ID, hs.id AS HS_ID,
st_area (st_symmetricdiff (st_buffer (hs.location, .1), sa.zone)) AS "no intersection"
FROM hazardous_sites hs, sensitive_areas sa
WHERE hs.id = 4;

    sa_id   sa_id   no intersection

         1        4    100.031393
         2        4    400.031393
         3        4    400.015697

The symmetric difference of the hazardous waste sites and the sensitive areas results in the subtraction of the intersected areas.

See Also

  • An overview of SQL functions used with ST_Geometry types
  • Spatial operations