ST_INTERSECTS()
All functions > GEOSPATIAL > ST_INTERSECTS()
Returns TRUE if two geometries or geographies share any portion of space.
Signatures
Intersects
Returns: TRUE if the inputs intersect, FALSE otherwise
ST_INTERSECTS(geo1: T, geo2: T) → BOOLEAN sql
| Parameter | Type | Required | Description |
|---|---|---|---|
geo1 | T | Yes | First geometry or geography |
geo2 | T | Yes | Second geometry or geography |
With:
T: Custom types: GEOM_POINT | GEOM_LINESTRING | GEOM_POLYGON | GEOM_MULTIPOINT | GEOM_MULTILINESTRING | GEOM_MULTIPOLYGON | GEOM_MULTIANY | GEOG_POINT | GEOG_LINESTRING | GEOG_POLYGON | GEOG_MULTIPOINT | GEOG_MULTILINESTRING | GEOG_MULTIPOLYGON | GEOG_MULTIANY
Signature notes:
- Accepts any sub kind combination
- Equivalent to NOT ST_DISJOINT(a, b)
- Both inputs must be the same type family (both GEOMETRY or both GEOGRAPHY)
- Returns NULL if either input is NULL
- This is the most commonly used spatial predicate for spatial joins
Examples
Geometry
FeatureQL
SELECT
f1 := ST_INTERSECTS(ST_GEOMFROMTEXT('POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))'), ST_GEOMPOINT(1.0, 1.0)), -- Point inside polygon
f2 := ST_INTERSECTS(ST_GEOMFROMTEXT('POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))'), ST_GEOMPOINT(5.0, 5.0)) -- Point outside polygon
;Result
| f1 BOOLEAN | f2 BOOLEAN |
|---|---|
| true | false |
Geography
FeatureQL
SELECT
f1 := ST_INTERSECTS(ST_GEOGFROMTEXT('POLYGON ((2.29 48.85, 2.36 48.85, 2.36 48.87, 2.29 48.87, 2.29 48.85))'), ST_GEOGPOINT(2.33, 48.86)) -- Point in Paris polygon
;Result
| f1 BOOLEAN |
|---|
| true |
On this page