How the ST_Touches Geometry Checker works, and what it assumes
ST_Touches(A, B) is true when the geometries share at least one point but their interiors do not meet: every shared point is on the boundary of one or both. It is the test for neighbours, such as two parcels sharing a fence line, and for connected lines, such as two segments of a network meeting end to end. The DE-9IM patterns are FT*******, F**T***** and F***T****.
What counts as a boundary depends on the geometry. A polygon's boundary is its rings; a line's boundary is its two end points; a point has no boundary at all, which is why two points can never touch. The boundary-to-boundary cell of the matrix tells you how much the two share: 1 for a common edge, 0 for a single point.
Real data rarely touches exactly. Neighbouring polygons digitised separately usually leave a sliver gap or a sliver overlap along their shared edge, and then the answer is disjoint or overlapping rather than touching. The plot's pointer readout helps find where.
Where this comes up in GIS work
- Finding the neighbours of a parcel, a county or a census area.
- Checking that two line segments of a network meet end to end rather than crossing.
- Testing that polygons which should tile an area share their edges exactly, without gaps or overlaps.
A worked example
Two squares side by side, sharing part of an edge:
A: POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))
B: POLYGON ((4 1, 8 1, 8 5, 4 5, 4 1))
ST_Touches(A, B) = true
DE-9IM matrix: FF2F11212
Meeting only at a corner also counts: POLYGON ((4 4, 8 4, 8 8, 4 8, 4 4)) touches A with the matrix FF2F01212, a 0 where the first had a 1. Two lines meeting end to end, LINESTRING (0 0, 5 5) and LINESTRING (5 5, 10 0), touch too. Two identical points do not: they are equal instead.
Using the ST_Touches Geometry Checker
- Paste the first geometry into Geometry A, or select Load example.
- Paste the second geometry into Geometry B.
- Select Check ST_Touches, or press Ctrl + Enter (Cmd + Enter on a Mac).
- Read the verdict; the DE-9IM matrix shows whether they share an edge (1) or only a point (0) on their boundaries.
When the output looks wrong
- Neighbouring polygons do not touch
- Their shared edge is not exactly shared: the vertices differ by a tiny amount, leaving a sliver gap (then they are disjoint) or a sliver overlap (then they overlap). The matrix says which. Snapping the data to a common grid usually fixes it.
- Two identical points do not touch
- Points have no boundary, so two points can never touch; identical points are equal instead. For point data, compare with ST_Equals or ST_Intersects.
- A line that ends inside a polygon does not touch it
- Its end point is inside the polygon, not on its boundary, so the interiors meet. That is intersection, or crossing if the line also continues outside.
Questions about the ST_Touches Geometry Checker
What does ST_Touches mean?
That A and B share at least one point, and every shared point lies on the boundary of at least one of them: their interiors never meet. The DE-9IM patterns are FT*******, F**T***** and F***T****.
Do two polygons meeting at one corner touch?
Yes. A single shared boundary point is enough. The matrix shows 0 in the boundary-boundary cell for a point contact and 1 for a shared edge.
What is the boundary of a line?
Its two end points, unless the line is closed, in which case it has no boundary. So two lines touch when one's end point lies on the other and their interiors do not cross.
Is my data uploaded?
No. The calculation happens in your browser.