Name

ST_Simplify — Simplifies a Geometry using the standard Douglas-Peucker algorithm.

Synopsis

geometry ST_Simplify(bytea Geometry, double Tolerance);

Alias

Simplify

Description

Simplifies a Geometry using the standard Douglas-Peucker algorithm. Ensures that any polygonal geometries returned are valid. Simple lines are not guaranteed to remain simple after simplification (see ST_IsSimple).

The Tolerance parameter, sets the distance tolerance for the simplification. All vertices in the simplified geometry will be within this distance of the original geometry. The tolerance value must be positive.

Note that in general this method does not preserve topology - e.g. polygons can be split, collapse to lines or disappear, holes can be created or disappear, and lines can cross. To simplify geometry while preserving topology use ST_SimplifyPreserveTopology.

[Note]

This method supports GeometryCollections

Coordinate Dimensions
2D3DM
Spatial Standards Support
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
----

Examples

--2D Polygon--

SELECT ST_AsText(ST_Simplify(geom,2)) as s2,   ST_AsText(ST_Simplify(geom,5)) as s5, 
       ST_AsText(ST_Simplify(geom,10)) as s10, ST_AsText(ST_Simplify(geom,15)) as s15 
 FROM (SELECT ST_Buffer(ST_GeomFromText('POINT(50 50)'), 10) As geom) As foo;

--Result
S2
POLYGON ((60 50, 57.071067811865476 42.928932188134524, 50 40, 
42.928932188134524 42.928932188134524, 40 50.00000000000001, 42.92893218813454 57.07106781186549, 
50.00000000000002 60, 57.0710678118655 57.071067811865454, 60 50))

S5
POLYGON ((60 50, 50 40, 40 50.00000000000001, 50.00000000000002 60, 60 50))

S10
POLYGON ((60 50, 50 40, 40 50.00000000000001, 60 50))

S15
null

--3D LineString--
SELECT ST_AsText(ST_Simplify(geom,7.5)) as s7, ST_AsText(ST_Simplify(geom,10)) as s10 FROM 
(SELECT ST_GeomFromText('LINESTRING (5 15 10, 11 8 20, 19 22 30, 24 12 25, 38 20 35, 47 14 30, 55 23 20)') As geom) As foo;

--Result
S7
LINESTRING (5 15 10, 11 8 20, 19 22 30, 24 12 25, 55 23 20)

S10
LINESTRING (5 15 10, 55 23 20)

Related functions

ST_SimplifyPreserveTopology