ST_Generalize function
The ST_Generalize function takes a geometry and a threshold as input parameters and represents the specified geometry with a reduced number of points, while preserving the general characteristics of the geometry.
The Douglas-Peucker line-simplification algorithm is used, by which the sequence of points that define the geometry is recursively subdivided until a run of the points can be replaced by a straight line segment. In this line segment, none of the defining points deviates from the straight line segment by more than the specified threshold. Z and M coordinates are not considered for the simplification. The resulting geometry is in the spatial reference system of the specified geometry.
If the specified geometry is empty, an empty geometry of type ST_Point is returned. If the specified geometry or the threshold is null, null is returned.
Syntax
Parameter
- geometry
- A value of type ST_Geometry or one of its subtypes that represents the geometry for which the line-simplification is applied.
- threshold
- A value of type DOUBLE that identifies the threshold to be used for the line-simplification algorithm. The threshold must be greater than or equal to 0 (zero). The larger the threshold, the smaller the number of points that will be used to represent the generalized geometry.
Return type
ST_Geometry
Examples
In the following examples, the results have been reformatted for readability. The spacing in your results will vary according to your display.