turf.booleanTouches
What is turf.booleanTouches?
turf.booleanTouches returns true when two geometries share only boundary points — their interiors do not intersect. Per OGC, this is the predicate that captures "adjacent but not overlapping".
turf.booleanTouches(feature1, feature2) → booleanWhen would you use turf.booleanTouches?
Use turf.booleanTouches to detect adjacent features — neighbouring parcels that share a boundary, routes that meet at an endpoint, or polygons that abut without overlap. It is the right predicate for building adjacency graphs and continuity checks.
It is stricter than booleanIntersects: only edge contact counts, so overlapping or fully contained features return false.
const neighbours = parcels.features.filter(p => turf.booleanTouches(p, selected));FAQs
How do I install Turf.js to use this function?
Install npm install @turf/boolean-touches and import import { booleanTouches } from '@turf/boolean-touches', or use turf.booleanTouches via @turf/turf.
Does shared-edge contact count?
Yes — when two polygons share an edge (not just a vertex) and their interiors do not overlap, touches returns true. That is the classic adjacency case.
What if the geometries overlap?
touches returns false for any overlap. Use booleanOverlap for partial overlap or booleanIntersects for any contact.
Can I build an adjacency graph with booleanTouches?
Yes. Pair-test each polygon against its bbox neighbours (via a spatial index) and store true edges. For very large datasets, prefer a topology library like topojson-server that records adjacency during conversion.