turf.intersect
What is turf.intersect?
turf.intersect returns the shared area of two polygons as a Polygon or MultiPolygon — or null if they do not overlap. It is the spatial-operations equivalent of ST_Intersection in PostGIS and is built on the robust polygon-clipping library.
turf.intersect(featureCollection) → Feature<Polygon | MultiPolygon> | nullRecent versions accept a FeatureCollection<Polygon> with two features; older versions took two arguments. Check the package version in your project.
When would you use turf.intersect?
Use turf.intersect for any "region A that is also inside region B" query — for example, clipping a dataset to a selection polygon, computing the overlap between a hazard zone and a land parcel, or intersecting a user-drawn region with administrative boundaries to drive a filter UI.
In Node.js ETL, it is the primitive for land-cover classification, overlap analysis, and spatial joins where you need the geometry of the overlap (not just whether they intersect — for that use turf.booleanIntersects).
undefinedFAQs
What is returned when polygons do not overlap?
null. Always guard against null before passing the result to a map source or downstream operation.
How do I install just intersect?
npm install @turf/intersect. It depends on @turf/helpers and polygon-clipping.
Does it handle holes and MultiPolygon?
Yes. The underlying algorithm handles polygons with holes and MultiPolygon inputs, producing topologically valid results with correct winding.
Do I want intersect or booleanIntersects?
Use turf.intersect when you need the overlap geometry. Use turf.booleanIntersects when you only need a yes/no — it is significantly faster because it bails out on the first shared point.