This topic describes the ST_SimplifyPreserveTopology function. This function returns a geometry object representing a simplified version of the input geometry object. This function uses the Douglas-Peucker algorithm. This function prevents the return of an invalid geometry object.
Syntax
geometry ST_SimplifyPreserveTopology(geometry geomA , float tolerance);
Parameters
Parameter | Description |
---|---|
geomA | The geometry object that you want to specify. |
tolerance | The tolerance that you want to specify. |
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.
- This function prevents the return of a derived and invalid geometry object, especially polygon objects.
Examples
Comparison between the results of the ST_SimplifyPreserveTopology function and the
ST_Simplify function:
SELECT ST_ASText(ST_SimplifyPreserveTopology(g,1)) as PreserveTopology ,ST_ASText(ST_Simplify(g,1)) as Normal from (select 'POLYGON((0 0,1 0,0 1,1 1,0 0))'::geometry as g) as t;
preservetopology | normal
----------------------------+--------
POLYGON((0 0,1 0,1 1,0 0)) |
(1 row)