文档

ST_GeometricMedian

更新时间:

返回给定Geometry对象的几何中位点。

语法

geometry  ST_GeometricMedian (geometry  g , float8  tolerance , int  maxIter , boolean  failIfNotConverged);

参数

参数名称

描述

g

目标Geometry对象。

tolerance

容差。

maxIter

最大迭代次数。

failIfNotConverged

是否在超过迭代次数后依旧没有找到时报错。

描述

  • 该算法将不断迭代,直到对象之间的距离变化小于提供的公差参数为止。如果在maxIter次数之后未满足此条件,则该函数将产生错误并退出,除非failIfNotConverged设置为False。

  • 如果未提供tolerance,则将基于输入对象的范围计算默认tolerance。

  • 如果存在点的M值,则该值将被解释为它们的相对权重。

示例

对比ST_GeometricMedian和ST_Centroid

SELECT ST_AsText(ST_GeometricMedian(geom)) as GeometricMedian, ST_AsText(ST_Centroid(geom)) as Centroid
    from (SELECT 'MULTIPOINT((0 0), (0 1), (1 1), (2 0))'::geometry as geom) as test;
              geometricmedian               |    centroid
--------------------------------------------+-----------------
 POINT(0.665913838138866 0.666097415551148) | POINT(0.75 0.5)
(1 row)
                

12

  • 本页导读 (1)
文档反馈