【postgis】函数记录一丢丢-st_simplify、ST_SimplifyPreserveTopology

抽希函数。

st_simplify(geometry geom, float distanceTolerance);

第一个参数几何字段,第二个是容差,单位是数据拥有的坐标系单位。比如wgs84,单位就是°。

 

 

 

 

http://www.postgis.net/docs/ST_Simplify.html 

http://www.postgis.net/docs/ST_SimplifyPreserveTopology.html

 ST_SimplifyPreserveTopology对线的处理,没有效果图,因为处理后,线变为了多线,所以没法保存。

ERROR:  Geometry type (LineString) does not match column type (MultiLineString),可以用函数ST_Multi对ST_SimplifyPreserveTopology的处理结果(LineString)进行转换,使之成为MultiLineString。

st_simplify还重载了三个参数,第3个参数,如果为true,相当于加了一个规则,删点会比false少一些,解释看官方文档。

 

来自官方文档:

geometry ST_Simplify(geometry geomA, float tolerance, boolean preserveCollapsed);

The “preserve collapsed” flag will retain objects that would otherwise be too small given the tolerance. For example, a 1m long line simplified with a 10m tolerance. If the preserve flag is given, the line will not disappear. This flag is useful for rendering engines, to avoid having large numbers of very small objects disappear from a map leaving surprising gaps.

 

geometry ST_SimplifyPreserveTopology(geometry geomA, float tolerance);

Returns a “simplified” version of the given geometry using the Douglas-Peucker algorithm. Will avoid creating derived geometries (polygons in particular) that are invalid. Will actually do something only with (multi)lines and (multi)polygons but you can safely call it with any kind of geometry. Since simplification occurs on a object-by-object basis you can also feed a GeometryCollection to this function.

Performed by the GEOS module.

转载自:https://blog.csdn.net/hellolib/article/details/81663281

You may also like...