The ST_Intersects() function
The ST_Intersects() function returns t
(TRUE)
if the intersection of two geometries does not result in an empty
set; otherwise, returns f
(FALSE).
Syntax
ST_Intersects (g1 ST_Geometry, g2 ST_Geometry)
Usage
The results of the spatial relationship of the ST_Intersects() 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_Intersects() function returns TRUE if the conditions of any of the following pattern matrices returns TRUE.
Interior (b) | Boundary (b) | Exterior (b) | |
---|---|---|---|
Interior (a) | T | * | * |
Boundary (a) | * | * | * |
Exterior (a) | * | * | * |
Interior (b) | Boundary (b) | Exterior (b) | |
---|---|---|---|
Interior (a) | * | T | * |
Boundary (a) | * | * | * |
Exterior (a) | * | * | * |
Interior (b) | Boundary (b) | Exterior (b) | |
---|---|---|---|
Interior (a) | * | * | * |
Boundary (a) | T | * | * |
Exterior (a) | * | * | * |
Interior (b) | Boundary (b) | Exterior (b) | |
---|---|---|---|
Interior (a) | * | * | * |
Boundary (a) | * | T | * |
Exterior (a) | * | * | * |
Return type
BOOLEAN
Example
The fire marshal wants a list of sensitive areas within a 5-mile radius of a hazardous waste site.
CREATE TABLE sensitive_areas (id integer,
name varchar(128),
size float,
type varchar(10),
zone ST_Polygon);
CREATE TABLE hazardous_sites (site_id integer,
name varchar(40),
location ST_Point);
SELECT sa.name, hs.name
FROM sensitive_areas sa, hazardous_sites hs
WHERE ST_Intersects(ST_Buffer(hs.location,(5 * 5280)),sa.zone);
name Johnson County Hospital
name W. H. Kleenare Chemical Repository
name Johnson County Hospital
name Landmark Industrial
name Summerhill Elementary School
name Landmark Industrial