ST_INTERSECTION()

All functions > GEOSPATIAL > ST_INTERSECTION()

Returns the geometry/geography representing the point set intersection of two inputs.

Signatures

Intersection

Returns: Intersection; sub kind depends on overlap

ST_INTERSECTION(geo1: T, geo2: T) → GEOMETRY or GEOGRAPHY
sql
ParameterTypeRequiredDescription
geo1TYesFirst geometry or geography
geo2TYesSecond 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:

  • Two overlapping polygons produce a polygon
  • A polygon and a line produce line segments or points
  • Two disjoint geometries produce an empty geometry
  • ST_ASTEXT output may use either winding direction for rings; strict OGC exterior-ring orientation is not always preserved, so validate downstream systems that require a specific winding
  • Both inputs must be the same type family
  • Returns NULL if either input is NULL

Examples

FeatureQL
SELECT
    f1 := ST_ASTEXT(ST_INTERSECTION(ST_GEOMFROMTEXT('POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))'), ST_GEOMFROMTEXT('POLYGON ((1 1, 3 1, 3 3, 1 3, 1 1))'))) -- Intersection of two overlapping squares (WKT vertex order may be clockwise or counter-clockwise)
;
Result
f1 VARCHAR
POLYGON ((2 2, 2 1, 1 1, 1 2, 2 2))

Last update at: 2026/05/26 17:22:09