Turf.jsTransformation

turf.bezierSpline

What is turf.bezierSpline?

turf.bezierSpline takes a LineString and returns a smoothed version that passes through (or near) each original vertex, interpolated as a bezier spline. The smoothing is controlled by resolution and sharpness parameters.

JavaScript
turf.bezierSpline(line, options?) → Feature<LineString>

Options include:

  • resolution — time interval between points in milliseconds (default 10000); controls density of output points
  • sharpness — how sharply the curve passes through vertices, 0–1 (default 0.85)
  • properties — output feature properties

When would you use turf.bezierSpline?

Use turf.bezierSpline to visually smooth a zig-zag polyline — typical examples include raw GPS tracks, sketched paths, or a coarse route you want to present with aesthetic curves. It is a visual-only smoothing; the underlying spatial accuracy is approximate, so do not use it for measurement or topology.

On MapLibre, it is often paired with turf.simplify to first reduce noise, then smooth what remains for display. In Node.js, use it as the last step of a track-preparation pipeline producing pretty trails for a fitness or travel app.

Code
undefined

FAQs

Does the output pass exactly through the original vertices?

Approximately — sharpness controls how closely. Values near 1 pass very close to each input vertex; lower values produce more rounded curves that cut corners.

Is it suitable for measurement?

No. turf.bezierSpline changes the geometry. For accurate distance or area, measure on the original line and present the spline only for display.

How do I install just bezierSpline?

npm install @turf/bezier-spline. It depends on @turf/helpers and the small @turf/bezier-spline internal Spline helper.

What resolution should I pick?

The default 10000 works well for medium-length routes. Lower it for smoother, denser splines on short segments; increase for sparse outputs on long routes. The value is in "time" units used by the internal interpolator — experiment for your dataset.