Turf.jsTransformation

turf.convex

What is turf.convex?

turf.convex returns the tightest convex polygon containing all coordinates of the input features. It accepts any GeoJSON input — FeatureCollection, Polygon, LineString, Point — and returns a single Polygon Feature.

JavaScript
turf.convex(geojson, options?) → Feature<Polygon>

Options include:

  • concavity — value between 1 and Infinity; controls concavity. Infinity is fully convex (default), smaller values approach concave. Available in some versions via @turf/concaveman.
  • properties — output feature properties

When would you use turf.convex?

Use turf.convex when you need a simple, always-valid polygon summarising a set of features — for example, bounding customer locations for a coverage analysis, delimiting a search area around a set of POIs, or computing a basic service zone.

Convex hulls are computationally cheap and topologically safe (no self-intersection). They are the right choice when a loose envelope is acceptable; for shape-conforming outlines use turf.concave.

Code
undefined

FAQs

When should I use concave instead?

When the point set has noticeable clusters or gaps that the convex hull smooths over. turf.concave follows indentations and produces more realistic outlines for sparse, clustered data — at the cost of tuning maxEdge.

How do I install just convex?

npm install @turf/convex. It depends on @turf/helpers and @turf/meta; recent versions integrate with concaveman internally.

What if I have just two points?

turf.convex needs at least 3 non-collinear points to form a polygon. With fewer, it returns null or throws, depending on the version — handle the degenerate case in your wrapper code.

Does it preserve input properties?

No — the hull is a new polygon with the properties you pass in options (or empty by default). Input properties are not carried through because the hull can span many input features.