ST_Equals compares two geometries and returns 1 (TRUE) if the geometries are identical; otherwise it returns 0 (FALSE).
Syntax
db2gse.ST_Equals(g1 db2gse.ST_Geometry, g2 db2gse.ST_Geometry)
Return type
Integer
Examples
The city GIS technician suspects that some of the data in the BUILDINGFOOTPRINTS table was somehow duplicated. The technician queries the table to determine if any of the footprint's multipolygons are equal.
The BUILDINGFOOTPRINTS table is created with the following statement. The BUILDING_ID column uniquely identifies the buildings; the LOT_ID column identifies the building's lot; and the FOOTPRINT column stores the building's geometry.
CREATE TABLE BUILDINGFOOTPRINTS ( building_id integer, lot_id integer, footprint db2gse.ST_MultiPolygon);
The BUILDINGFOOTPRINTS table is spatially joined to itself by the ST_Equals predicate, which returns 1 whenever it finds two of the multipolygons that are equal. The bf1.building_id <> bf2.building_id condition is required to eliminate the comparison of the same geometry.
SELECT bf1.building_id, bf2.building_id FROM BUILDINGFOOTPRINTS bf1, BUILDINGFOOTPRINTS bf2 WHERE db2gse.ST_Equals(bf1.footprint,bf2.footprint) = 1 and bf1.building_id <> bf2.building_id;