ST_Touches()

Returns 1 when the geometries have no interior intersection and at least one geometry’s boundary intersects the other.

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. The relationship is evaluated using planar coordinate semantics; matching SRID 4326 inputs are accepted, but this does not provide geodetic predicate semantics.

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().