ST_SimplifyPreserveTopology — Simplifies a geometry, ensuring that the result is a valid geometry having the same dimension and number of components as the incoming geometries.
varchar
ST_SimplifyPreserveTopology(
bytea
Geometry, double
Tolerance)
;
Simplifies a geometry, ensuring that the result is a valid geometry having the same dimension and number of components as the given geometries. The simplification uses a maximum distance difference algorithm similar to the one used in the Douglas-Peucker algorithm. In particular, if the input is an areal geometry ( Polygon or MultiPolygon).
The result has the same number of shells and holes (rings) as the input, in the same order
The result rings touch at no more than the number of touching point in the input (although they may touch at fewer points)
This method supports GeometryCollections |
2D | 3D | M |
---|---|---|
OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
---|---|---|---|
- | - | - | - |
--polygon with holes SELECT ST_AsText(ST_Simplify(geom,4)) as s4, ST_AsText(ST_SimplifyPreserveTopology(geom,4)) as preserve4 FROM (SELECT ST_GeomFromText('POLYGON ((16 7, 16 36, 47 36, 47 7, 16 7), (24 16, 24 24, 30 24, 30 16, 24 16), (38 27, 38 31, 43 31, 43 27, 38 27), (36 12, 36 19, 43 19, 43 12, 36 12))') As geom) As foo; --Result: S4 POLYGON ((16 7, 16 36, 47 36, 47 7, 16 7), (24 16, 24 24, 30 24, 30 16, 24 16), (36 12, 36 19, 43 19, 43 12, 36 12)) PRESERVE4 POLYGON ((16 7, 16 36, 47 36, 47 7, 16 7), (24 16, 24 24, 30 24, 30 16, 24 16), (38 27, 38 31, 43 31, 43 27, 38 27), (36 12, 36 19, 43 19, 43 12, 36 12))
GeomA | ST_Simplify(GeomA,4) | ST_SimplifyPreserveTopology (GeomA,4) |