ST_SetEffectiveArea
What is ST_SetEffectiveArea?
ST_SetEffectiveArea is a PostGIS function that computes the Visvalingam-Whyatt effective area for each vertex of a geometry and stores it in the vertex's M coordinate. Vertices with larger effective areas are more significant for shape — those with small values are the first candidates for simplification.
ST_SetEffectiveArea(geometry geom, float threshold = 0, integer set_area = 1) → geometryWith threshold = 0, every vertex gets an M-value and no vertex is dropped. With a positive threshold, vertices below that threshold are removed.
When would you use ST_SetEffectiveArea?
Use ST_SetEffectiveArea when you want progressive simplification — storing effective areas once so that multiple simplification levels can be derived cheaply by filtering on M-values. It powers zoom-dependent rendering in vector-tile pipelines where each zoom level shows progressively more vertices.
1SELECT id, ST_FilterByM(ST_SetEffectiveArea(geom), :zoom_threshold) AS tile_geom
2FROM features;FAQs
How is this different from ST_SimplifyVW?
ST_SimplifyVW applies the Visvalingam-Whyatt algorithm and drops vertices below a threshold in one pass. ST_SetEffectiveArea computes and stores the per-vertex effective area without dropping, so you can decide later — or at multiple thresholds — which vertices to keep. The two are typically used together via ST_FilterByM.
What are the units of the effective area?
Squared units of the input's SRID. For UTM that is m²; for EPSG:4326 that is degree². For meaningful, comparable thresholds, reproject to a metric CRS before calling.
Does it overwrite existing M-values?
Yes, by default. If your geometry already carries M-values you want to keep (e.g. timestamps), consider calling ST_SetEffectiveArea on a copy and storing the results separately.
Why is this useful for vector tiles?
At different zoom levels you want different levels of detail. By pre-computing effective areas once, you can serve each zoom level by filtering vertices whose M-value exceeds a zoom-dependent threshold — much cheaper than running a full simplification per tile.