PostGISGeometry Processing

ST_ChaikinSmoothing

What is ST_ChaikinSmoothing?

ST_ChaikinSmoothing is a PostGIS function that applies Chaikin's corner-cutting algorithm to smooth the input geometry. Each iteration replaces every corner with two new points at 1/4 and 3/4 along the adjoining edges, gradually converting angular shapes into rounded, curve-like geometries.

SQL
ST_ChaikinSmoothing(geometry geom, integer nIterations = 1, boolean preserveEndPoints = false)geometry

More iterations produce smoother curves but quadruple the vertex count each time. preserveEndPoints = true keeps LineString endpoints fixed, which matters for open paths.

When would you use ST_ChaikinSmoothing?

Use ST_ChaikinSmoothing for cartographic styling — softening hand-drawn polygons, smoothing GPS tracks, or turning generalised administrative boundaries into more organic shapes for presentation. It is also useful as a quick way to approximate curves from piecewise-linear input.

SQL
1SELECT ST_ChaikinSmoothing(geom, 3, true) AS smoothed_track
2FROM gps_tracks
3WHERE id = 42;

FAQs

How many iterations should I use?

Two or three iterations usually give a pleasing smooth result. Each iteration roughly quadruples the vertex count, so five or more iterations can produce enormous geometries and slow down rendering. Start with nIterations = 2 and increase only if needed.

Does ST_ChaikinSmoothing preserve topology?

No. Chaikin smoothing is a purely geometric operation — it can shift boundaries inward and may cause small polygons to overlap with neighbours after smoothing. For adjacency-preserving smoothing of polygon coverages, use ST_CoverageSimplify instead.

Why are my polygon corners still sharp at the start and end?

For closed rings the algorithm smooths all corners uniformly. For open LineString inputs with preserveEndPoints = true, the first and last vertices are held fixed and therefore remain sharp. Set preserveEndPoints = false to smooth the endpoints as well (at the cost of trimming the line slightly).

Is there a way to reduce vertex explosion?

Yes — pair ST_ChaikinSmoothing with ST_SimplifyPreserveTopology afterwards to trim near-collinear points, or run ST_Simplify on the input first to reduce the starting vertex count before smoothing.