返回給定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)

