[postgis-users] ST_Touches and line segment

Kevin Neufeld kneufeld at refractions.net
Thu Mar 19 09:18:42 PDT 2009


Martin Landa wrote:
> Hi,
> 
> AFAIU ST_Touches() returns True if two objects share at least one point (node).

Actually, this is a partial truth.  ST_Touches(g1,g2) returns TRUE if the only points in common between g1 and g2 lie in 
the union of the boundaries of g1 and g2.  This means that it will also return TRUE for objects that share a boundary 
line (AND whose interiors are not overlapping).  See the examples in the new PostGIS docs:
http://postgis.refractions.net/documentation/manual-svn/ST_Touches.html

> 
> Is there a way how to test whether objects share at least one line
> segment (i.e. two points/nodes).
> 
> Thanks in advance, Martin
> 

If you have overlapping polygons then use ST_Relate with a custom matrix.  IE. ST_Relate(g1, g2, '****1****') will 
return TRUE for all geometry pairs where the intersection of the boundaries occur on a line (1).

Cheers,
Kevin



More information about the postgis-users mailing list