ST_TOUCHES()

All functions > GEOSPATIAL > ST_TOUCHES()

Returns TRUE if two geometries share boundary points but no interior points.

Signatures

Touches

Returns: TRUE if A and B touch

ST_TOUCHES(geo1: T, geo2: T) → BOOLEAN
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 geometries touch if they share boundary points but their interiors do not intersect
  • Point to Point always returns FALSE (points have no boundary)
  • Both inputs must be the same type family
  • Returns NULL if either input is NULL

Examples

FeatureQL
SELECT
    f1 := ST_TOUCHES(ST_GEOMFROMTEXT('POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))'), ST_GEOMPOINT(2.0, 1.0)), -- Point on polygon boundary
    f2 := ST_TOUCHES(ST_GEOMFROMTEXT('POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))'), ST_GEOMPOINT(1.0, 1.0)) -- Point inside polygon interior: not touching
;
Result
f1 BOOLEANf2 BOOLEAN
truefalse

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