turf.concave
What is turf.concave?
turf.concave takes a FeatureCollection<Point> and returns a Polygon (or MultiPolygon) that forms a concave hull around the points. It uses an alpha-shape style algorithm with a maxEdge parameter that caps how long an edge can be — smaller values produce tighter, more concave hulls.
turf.concave(points, options?) → Feature<Polygon | MultiPolygon> | nullOptions include:
maxEdge— longest allowed edge in the hull (defaultInfinity, equivalent to convex)units— distance units formaxEdge(default'kilometers')
When would you use turf.concave?
Use turf.concave when a convex hull is too coarse — for example, to show the outline of a city's coverage area from GPS pings, the footprint of a habitat from animal sightings, or the rough shape of a user-defined cluster. Unlike turf.convex, turf.concave follows indentations in the data.
In Node.js, it is useful for summarising where events occurred (e.g. visualising the territory covered by a delivery fleet for the day). Tune maxEdge carefully — too small and the hull fragments into multiple polygons; too large and it collapses to the convex hull.
undefinedFAQs
What does maxEdge control?
It is the longest triangle edge allowed when the algorithm builds the hull. Smaller values = tighter, more indented hulls. If maxEdge is too small for your data density, the result can be null or a fragmented MultiPolygon.
When does it return null?
When the point set is too sparse for the requested maxEdge (no triangles survive the filter). Increase maxEdge or add more input points.
How do I install just concave?
npm install @turf/concave. It depends on @turf/tin (Delaunay triangulation) and @turf/helpers.
How does it differ from convex?
turf.convex returns the tightest convex polygon containing all points — may include large empty regions for clustered data. turf.concave follows indentations and is more visually representative for real clusters.