名称

ST_SimplifyVW — 使用Visvalingam-Whyatt算法返回几何图形的简化表示

大纲

geometry ST_SimplifyVW(geometry geom, float tolerance);

描述

Returns a simplified representation of a geometry using the Visvalingam-Whyatt algorithm. The simplification tolerance is an area value, in squared units of the input SRS. Simplification removes vertices which form "corners" with area less than the tolerance. The result may not be valid even if the input is.

该函数可用于任何类型的几何图形(包括GeometryCollections),但只有线和多边形元素会被简化。线性几何的端点将被保留。

[注意]

返回的几何图形可能会失去其简单性(参见ST_IsSimple),拓扑可能不会被保留,并且多边形的结果可能是无效的(参见ST_IsValid)。使用ST_SimplifyPreserveTopology来保留拓扑并确保有效性。ST_CoverageSimplify也会保留拓扑和有效性。

This is a general-purpose simplification function. It may remove narrow polygon spikes when their effective area is below the tolerance, but it is not a dedicated spike-removal or polygon-repair operation. Use ST_IsValid to check the result and ST_MakeValid to repair invalid polygonal output if needed.

该函数不保留多边形之间共享的边界。如果需要保留共享边界,请使用ST_CoverageSimplify

该函数处理 3D,第三维将影响结果。

可用性:2.2.0

示例

This polygon has a narrow spike whose effective area is small enough to be removed by a tolerance of 20 square units.

Code
SELECT geom AS original, ST_SimplifyVW(geom, 20) AS simplified
FROM (SELECT 'POLYGON((0 0,10 0,10 10,5.2 10,5 16,4.8 10,0 10,0 0))'::geometry AS geom) AS t;
栅格输出
POLYGON((0 0,10 0,10 10,5.2 10,5 16,4.8 10,0 10,0 0)) | POLYGON((0 0,10 0,10 10,0 10,0 0))
Figure
Geometry figure for visual-st-simplifyvw-01

A LineString is simplified with a minimum-area tolerance of 30. For a linear simplification using ST_Simplify, a comparable tolerance would be a length in input-SRS units, so the value here is roughly that linear tolerance squared.

Code
SELECT ST_SimplifyVW(geom, 30) simplified
  FROM (SELECT 'LINESTRING(5 2,3 8,6 20,7 25,10 10)'::geometry AS geom) AS t;
栅格输出
LINESTRING(5 2,7 25,10 10)
Figure
Geometry figure for visual-st-simplifyvw-02

对一条线进行简化。

Code
SELECT ST_SimplifyVW('LINESTRING (10 10,50 40,30 70,50 60,70 80,50 110,100 100,90 140,100 180,150 170,170 140,190 90,180 40,110 40,150 20)'::geometry,
1600);
栅格输出
LINESTRING(10 10,100 100,100 180,150 170,190 90,150 20)
Figure
Geometry figure for visual-st-simplifyvw-03

对多边形进行简化。

Code
SELECT ST_SimplifyVW('POLYGON ((20 20,50 60,20 120,40 170,80 180,120 140,180 180,160 130,180 100,180 30,130 70,150 10,20 20))'::geometry,
1600);
栅格输出
POLYGON((20 20,20 120,80 180,160 130,180 30,20 20))
Figure
Geometry figure for visual-st-simplifyvw-04