The ST_Overlaps() function

The ST_Overlaps() function returns t (TRUE) if the intersection of two ST_Geometry objects results in an ST_Geometry object of the same dimension but not equal to either source object. Otherwise, it returns f (FALSE).

Syntax

ST_Overlaps(g1 ST_Geometry, g2 ST_Geometry)

Usage

The following figure shows various geometric objects that overlap.
Figure 1. Overlapping geometries
This graphic shows various geometric objects that overlap.

The results of the spatial relationship of the ST_Operlaps() function can be understood or verified by comparing the results with a pattern matrix that represents the acceptable values for the DE-9IM. The ST_Operlaps() function returns TRUE if the intersection of the objects results in an object of the same dimension but not equal to either source object.

This pattern matrix applies to ST_Polygon and ST_Polygon; ST_MultiPoint and ST_MultiPoint; and ST_MultiPolygon and ST_MultiPolygon overlaps. For these combinations, the ST_Overlaps() function returns TRUE if the interior of both geometries intersects the other's interior and exterior.
Table 1. Pattern matrix for the ST_Overlaps() function
  Interior (b) Boundary (b) Exterior (b)
Interior (a) T * T
Boundary (a) * * *
Exterior (a) T * *
This pattern matrix applies to ST_LineString and ST_LineString; and to ST_MultiLineString and ST_MultiLineString overlaps. In this case, the intersection of the geometries must result in a geometry that has a dimension of 1 (another ST_LineString or ST_MultiLineString). If the dimension of the intersection of the interiors resulted in 0 (a point), the ST_Overlaps() function would return FALSE; however, the ST_Crosses() function would return TRUE.
  Interior (b) Boundary (b) Exterior (b)
Interior (a) 1 * T
Boundary (a) * * *
Exterior (a) T * *

Return type

BOOLEAN

Example

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

The sensitive_areas table contains several columns that describe the threatened institutions in addition to the zone column, which stores the institution ST_Polygon geometries:
CREATE TABLE sensitive_areas (id     integer,
                              name   varchar(128),
                              size   float,
                              type   varchar(10),
                              zone   ST_Polygon);
The hazardous_sites table stores the identity of the sites in the site_id and name columns. The actual geographic location of each site is stored in the location point column:
CREATE TABLE hazardous_sites (site_id   integer,
                              name      varchar(40),
                              location  ST_Point);
The sensitive_areas and hazardous_sites tables are joined by the ST_Overlaps() function. It returns t (TRUE) for all sensitive_areas rows whose zone polygons overlap the buffered 5-mile radius of the hazardous_sites location points:
SELECT hs.name hazardous_site, sa.name sensitive_area 
   FROM hazardous_sites hs, sensitive_areas sa
   WHERE ST_Overlaps(ST_Buffer(hs.location,(26400)),sa.zone);


hazardous_site  Landmark Industrial
sensitive_area  Johnson County Hospital

hazardous_site  Landmark Industrial
sensitive_area  Summerhill Elementary School
The following figure shows that the hospital and the school overlap the 5-mile radius of the county's two hazardous waste sites. The nursing home does not.
Figure 2. Using the ST_Overlaps() function
This graphic is described in the surrounding text.

Copyright© 2019 HCL Technologies Limited