ST_SimplifyVW

更新时间:
复制 MD 格式

Returns a simplified version of a geometry using the Visvalingam-Whyatt algorithm. The algorithm measures the importance of each vertex by the area of the triangle it forms with its two neighbors, removing vertices whose triangle area falls below the tolerance threshold.

Syntax

geometry ST_SimplifyVW(geometry geomA, float tolerance)

Parameters

ParameterDescription
geomAThe input geometry to simplify.
toleranceThe tolerance that you want to specify.

Usage notes

  • Applies simplification to MultiLine, MultiPolygon, and MultiPoint geometries. You can use this function to process any geometry objects.

  • Processes each geometry in a GeometryCollection independently, so GeometryCollection inputs are supported.

  • Supports 3D geometries. The Z coordinate of input vertices affects which vertices are removed.

The returned geometry may not be simple (see ST_IsSimple), and the function may change the topology of the input geometry and return an invalid geometry object. Use ST_SimplifyPreserveTopology to preserve topology and ensure valid results.

Examples

The following example compares ST_Simplify and ST_SimplifyVW on the same input geometry.

SELECT g,
       ST_Simplify(g, 0.5),
       ST_SimplifyVW(g, 0.5)
FROM (
  SELECT 'LINESTRING(0 0,2 2,3 1,3.5 1.5,5 0,5.25 0.25,5.5 0)'::geometry AS g
) AS t;

123

What's next

  • ST_SimplifyPreserveTopology — Simplifies a geometry while preserving topology and validity.

  • ST_Simplify — Simplifies a geometry using the Douglas-Peucker algorithm, with a distance-based tolerance.