User's Guide and Reference

ST_Overlaps

ST_Overlaps takes two geometry objects and returns 1 (TRUE) if the intersection of the objects results in a geometry object of the same dimension but not equal to either source objects; otherwise it returns 0 (FALSE).

Syntax

db2gse.ST_Overlaps(g1 db2gse.ST_Geometry, g2 db2gse.ST_Geometry)

Return type

Integer

Examples

The county supervisor needs a list of hazardous waste sites whose five-mile radius overlaps sensitive areas.

The following CREATE TABLE statement creates the SENSITIVE_AREAS table. The SENSITIVE_AREAS table contains several columns that describe the threatened institutions in addition to the ZONE column, which stores the institution's polygon geometry.

CREATE TABLE SENSITIVE_AREAS (id        integer,
                              name      varchar(128),
                              size      float,
                              type      varchar(10),
                              zone      db2gse.ST_Polygon); 

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.

CREATE TABLE HAZARDOUS_SITES (site_id   integer,
                              name      varchar(128),
                              location  db2gse.ST_Point); 

In the following SELECT statement, the SENSITIVE_AREAS and HAZARDOUS_SITES tables are joined by the ST_Overlaps function. It returns 1 (TRUE) for all rows in the SENSITIVE_AREAS table whose zone polygons overlap the buffered five-mile radius of the HAZARDOUS_SITES location point.

SELECT hs.name
FROM HAZARDOUS_SITES hs, SENSITIVE_AREAS sa
WHERE db2gse.ST_Overlaps (buffer(hs.location,(5 * 5280)),sa.zone) = 1; 

In Figure 37, the hospital and the school overlap the five-mile radius of the county's two hazardous waste sites, while the nursing home does not.

Figure 37. Using ST_Overlaps to determine the buildings that are at least partially within of a hazardous waste area


top


[ Top of Page | Previous Page | Next Page ]