ST_SimplifyVW
What is ST_SimplifyVW?
ST_SimplifyVW is a PostGIS function that simplifies a geometry using the Visvalingam-Whyatt algorithm. Rather than measuring perpendicular distance (as Douglas-Peucker does), it repeatedly removes the vertex whose surrounding triangle has the smallest area, until no triangle remains below the given threshold.
ST_SimplifyVW(geometry geom, float tolerance) → geometrytolerance is the effective-area threshold in squared units of the input's SRID.
When would you use ST_SimplifyVW?
Use ST_SimplifyVW when visual smoothness matters more than strict shape preservation — simplifying coastlines or hand-drawn sketches for display, generalising rivers for a small-scale map, or preparing natural features for low-zoom vector tiles. Visvalingam-Whyatt tends to produce more natural-looking generalisation than Douglas-Peucker.
1SELECT river_id, ST_SimplifyVW(geom, 1000) AS simplified
2FROM rivers;FAQs
How is ST_SimplifyVW different from ST_Simplify?
ST_Simplify uses Douglas-Peucker, which removes vertices whose perpendicular offset is small — good for preserving sharp corners and crisp edges. ST_SimplifyVW uses effective-area, which tends to preserve visual character in natural shapes at the cost of minor shape drift. For coastlines, rivers, and organic features, VW typically looks better at low vertex counts.
What units is the tolerance in?
Squared units of the input's SRID — for UTM that is square metres, for EPSG:4326 that is square degrees. A tolerance of 1000 with UTM keeps only vertices whose effective triangle is larger than 1000 m². Reproject to a metric CRS first for intuitive values on lat/lon data.
Can the output become invalid?
Yes, at high tolerance the algorithm can create self-intersections just like ST_Simplify. It does not guarantee validity. If you need topology-safe simplification, use ST_SimplifyPreserveTopology (Douglas-Peucker) or ST_CoverageSimplify for polygon coverages.
How does this relate to ST_SetEffectiveArea?
ST_SetEffectiveArea computes and stores the Visvalingam effective area as the M-value of each vertex without actually dropping any. You can then use those values for your own filtering or progressive simplification. ST_SimplifyVW just does the drop in one pass.