This topic describes the ST_ChaikinSmoothing function. This function returns a geometry object representing a smoother version of the input geometry object. This function uses the Chaikin algorithm.

Syntax

geometry  ST_ChaikinSmoothing(geometry  geom , integer  nIterations , boolean  preserveEndPoints);

Parameters

Parameter Description
geom The geometry object that you want to specify.
nIterations The number of iterations that you want to specify. Maximum value: 5. Default value: 1.
preserveEndPoints The flag that specifies whether to keep the endpoints of the input geometry object. Default value: false. This parameter takes effects only when the input geometry object is a polygon object.

Description

  • For each iteration operation, this function doubles the number of vertexes of the input geometry object.
    • The function places a new vertex at one fourth of the lines before and after each point of the input geometry object and removes the original point.
    • The new points are interpolated values for all inherent dimensions of the input geometry object, including z and m dimensions.
  • The returned geometry object contains more points than the input geometry object. If you want to reduce the number of points of the returned geometry object, you use the ST_Simplify function or the ST_SimplifyVW function.

Examples

Results returned with different values of the nIterations parameter:
select g,ST_ChaikinSmoothing(g,1),
             ST_ChaikinSmoothing(g,5)
       from (select 'LINESTRING(0 0,2 2,3 1,3.5 1.5,5 0,5.25 0.25,5.5 0)'::geometry as g) as t;
123