Turf.jsBooleans

turf.booleanIntersects

What is turf.booleanIntersects?

turf.booleanIntersects returns true when two geometries share at least one point — the most permissive of the spatial predicates. It is the logical complement of turf.booleanDisjoint.

JavaScript
turf.booleanIntersects(feature1, feature2, options?) → boolean

Options include:

  • ignoreSelfIntersections — when true, ignores self-intersections in the inputs (default true)

When would you use turf.booleanIntersects?

Use turf.booleanIntersects for broad-phase filtering — picking every parcel that has any contact with a bounding box before running a more expensive predicate, or detecting whether a proposed route enters a restricted zone at all.

Because it covers every form of contact (crossing, touching, overlapping, containing), it is the right default when the question is simply "do these geometries touch in any way?". For more specific relationships, switch to booleanContains, booleanCrosses, or booleanOverlap.

JavaScript
const hits = parcels.features.filter(p => turf.booleanIntersects(p, selectionBox));

FAQs

How do I install Turf.js to use this function?

Install npm install @turf/boolean-intersects and import import { booleanIntersects } from '@turf/boolean-intersects', or via @turf/turf.

Is it faster than turf.lineIntersect?

Yes — booleanIntersects short-circuits on the first shared point instead of computing every intersection. Use lineIntersect when you need the intersection points themselves.

Does it require matching geometry types?

No. It works across Points, LineStrings, Polygons, and their Multi- variants in any combination.

How should I scale to large datasets?

Use a spatial index (rbush, flatbush) to prune candidate pairs by bounding box, then call booleanIntersects only on the survivors. Most production workflows wrap Turf predicates behind such indices.