Skip to main content

ST_Touches

Tests whether two geometries touch at their boundaries but their interiors do not intersect.

Syntax​

ST_Touches(geometry_a, geometry_b)

Parameters​

ParameterTypeDescription
geometry_aGeometryFirst geometry
geometry_bGeometrySecond geometry

Returns​

TypeDescription
BooleanTrue if geometries touch, false otherwise

Examples​

Adjacent Polygons​

SELECT ST_Touches(
ST_GeomFromText('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))'),
ST_GeomFromText('POLYGON((2 0, 4 0, 4 2, 2 2, 2 0))')
);
-- Returns: true (share edge at x=2)

Point on Polygon Boundary​

SELECT ST_Touches(
ST_Point(0, 1),
ST_GeomFromText('POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))')
);
-- Returns: true (point is on boundary)

Find Adjacent Regions​

SELECT a.name as region_a, b.name as region_b
FROM regions a, regions b
WHERE a.id < b.id
AND ST_Touches(a.geom, b.geom);

Notes​

  • Geometries touch if they share boundary points but no interior points
  • Useful for finding adjacent parcels or neighboring regions
  • Two points can never touch (they either equal or disjoint)
  • Returns false if interiors overlap

See Also​