ST_Touches()

Returns 1 when two geometries touch at their boundaries without overlapping interiors.

Syntax

ST_Touches(geom1, geom2)

Aliases: none.

Arguments

geom1 and geom2 are GEOMETRY values.

Return Value

Returns BOOL.

Usage Notes

  • Both geometries must have the same SRID. Predicates are Cartesian (SRID 0), not geodetic SRID 4326 predicates.

Examples

DROP DATABASE IF EXISTS geo_touches_demo;
CREATE DATABASE geo_touches_demo;
USE geo_touches_demo;

SELECT ST_Touches(ST_GeomFromText('LINESTRING(0 0, 2 0)'), ST_GeomFromText('LINESTRING(2 0, 4 0)')) AS lines_touch;

DROP DATABASE geo_touches_demo;

See Also

ST_Intersects(), ST_Crosses().