ST_Simplify
What is ST_Simplify?
ST_Simplify is a PostGIS function that simplifies a geometry using the Douglas-Peucker algorithm. It removes vertices whose perpendicular distance from the simplified line is smaller than the supplied tolerance, producing a lighter geometry that approximates the original.
ST_Simplify(geometry geom, float tolerance, boolean preserveCollapsed = false) → geometrytolerance is in the units of the input's SRID. preserveCollapsed = true keeps features that would otherwise be simplified away to nothing.
When would you use ST_Simplify?
Use ST_Simplify to reduce vertex counts for rendering, tiling, or transmission when topological correctness is not critical — simplifying a raw GPS track for display, shrinking overly-detailed coastlines for a small-scale map, or preparing geometries for vector tiles. It is fast and simple, but can produce invalid or non-adjacent polygons.
1SELECT id, ST_Simplify(geom, 0.0001) AS simplified
2FROM country_borders;FAQs
Should I use ST_Simplify or ST_SimplifyPreserveTopology?
ST_Simplify is faster but can produce invalid polygons and broken adjacencies. Use it for lines or when you're OK with the result. ST_SimplifyPreserveTopology is slightly slower but guarantees valid output — prefer it for polygons you'll display without post-cleanup.
How does this compare to ST_SimplifyVW?
Douglas-Peucker (used here) removes vertices based on perpendicular distance, preserving shape. Visvalingam-Whyatt (ST_SimplifyVW) removes vertices based on triangular effective area, tending to preserve visual character at the cost of minor shape drift. DP is better for crisp outlines; VW is often nicer for hand-drawn or natural features.
What units is the tolerance in?
The same units as the input geometry's SRID. For EPSG:4326 that is degrees (so 0.0001 is roughly 11 metres at the equator); for EPSG:3857 or UTM it is metres. If you need metre-based tolerances on lat/lon data, reproject first.
Can ST_Simplify invalidate polygons?
Yes — aggressive tolerance can cause polygon rings to self-intersect or collapse, and neighbouring polygons can develop gaps or overlaps. If validity matters, prefer ST_SimplifyPreserveTopology (for single polygons) or ST_CoverageSimplify (for adjacent polygon sets).