PostGISGeometry Processing

ST_SimplifyPreserveTopology

What is ST_SimplifyPreserveTopology?

ST_SimplifyPreserveTopology is a PostGIS function that applies the Douglas-Peucker simplification algorithm while guaranteeing that the result remains a valid, non-self-intersecting geometry. It achieves this by stopping short of collapses that would break validity.

SQL
ST_SimplifyPreserveTopology(geometry geom, float tolerance)geometry

tolerance is in the units of the input's SRID. The simplification is per-feature — adjacent polygons are not coordinated (use ST_CoverageSimplify for that).

When would you use ST_SimplifyPreserveTopology?

Use ST_SimplifyPreserveTopology when you need to reduce vertex counts on individual polygons without producing invalid output — generalising admin boundaries for a small-scale map, preparing features for a vector tile pipeline, or speeding up rendering. It is slower than ST_Simplify but safer.

SQL
1SELECT id, ST_SimplifyPreserveTopology(geom, 100) AS display_geom
2FROM admin_regions
3WHERE country = 'FR';

FAQs

How is this different from ST_Simplify?

Both use Douglas-Peucker, but ST_Simplify can produce self-intersecting or invalid geometries at high tolerance. ST_SimplifyPreserveTopology skips simplification that would break validity — the result may keep more vertices than strictly needed, but it is always a valid single-feature geometry.

Does it preserve adjacency between polygons?

No. Each geometry is simplified independently, so shared borders between neighbouring polygons can develop gaps or overlaps. For topology-preserving simplification of adjacent polygons, use ST_CoverageSimplify.

What if the tolerance is too aggressive?

The function will stop simplifying where further simplification would produce an invalid geometry. As a result, very high tolerances may still leave complex features with many vertices. The safest approach is to iterate — start with a modest tolerance and raise it until you hit your size target.

What units is the tolerance in?

The same units as the input's SRID — metres for UTM, degrees for EPSG:4326. For mixed-CRS inputs, reproject to a common projected CRS first to make tolerance values meaningful.