This topic describes the ST_Simplify function. This function returns a geometry object representing a simplified version of the input geometry object. This function uses the Douglas-Peucker algorithm.

Syntax

geometry  ST_Simplify(geometry  geomA , float  tolerance , boolean  preserveCollapsed);

Parameters

Parameter Description
geomA The geometry object that you want to specify.
tolerance The tolerance that you want to specify.
preserveCollapsed The flag that specifies whether to keep small geometry objects in the returned geometry object.

Description

  • This function supports simplification operations only on MultiLine objects, MultiPolygon objects, and MultiPoint objects. However, you can use this function to process any geometry objects.
  • The simplification operation is performed on the input geometry objects one by one. Therefore, you can use this function to process GeometryCollection objects.
  • If the scale of the input geometry object is much smaller than the value of the tolerance parameter and the preserveCollapsed parameter is specified, the input geometry object does not disappear.

    The preserveCollapsed parameter is useful to render engines to prevent a large number of small geometry objects from disappearing from maps and leaving abnormal gaps.

  • The returned geometry object may lose its simplicity.
  • This function may change the topology of the input geometry object and return an invalid geometry object.

    You can use the ST_SimplifyPreserveTopology function to preserve the topology of the input geometry object.

Examples

Results returned with different values of the tolerance parameter:
select g,ST_Simplify(g,0.25),
             ST_Simplify(g,0.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