ST_Simplify
Simplifies a geometry using the Douglas-Peucker algorithm.
Syntax
ST_Simplify(geometry, tolerance)
Parameters
| Parameter | Type | Description |
|---|---|---|
| geometry | Geometry | Input geometry |
| tolerance | Float64 | Distance tolerance for simplification |
Returns
| Type | Description |
|---|---|
| Binary (WKB) | Simplified geometry as WKB with geoarrow.wkb metadata |
Examples
Simplify LineString
SELECT ST_Simplify(
ST_GeomFromText('LINESTRING(0 0, 1 0.1, 2 0, 3 0.1, 4 0)'),
0.2
);
-- Returns: LINESTRING(0 0, 4 0) - removes small variations
Simplify Polygon
SELECT ST_Simplify(geom, 0.001) as simplified
FROM coastlines;
Compare Original and Simplified
SELECT
ST_NumPoints(geom) as original_points,
ST_NumPoints(ST_Simplify(geom, 0.01)) as simplified_points
FROM roads;
Varying Tolerance
SELECT id,
ST_Simplify(geom, small_tolerance) as detail,
ST_Simplify(geom, large_tolerance) as overview
FROM boundaries;
Notes
- Larger tolerance = more simplification
- May produce invalid geometries (self-intersections)
- Use ST_SimplifyPreserveTopology if validity is required
- Points remain unchanged
- Tolerance is in geometry coordinate units
See Also
- ST_SimplifyPreserveTopology - Topology-safe simplification
- ST_NumPoints - Count points
- ST_IsValid - Check validity