ST_GeometricMedian¶
Introduction: Computes the approximate geometric median of a MultiPoint geometry using the Weiszfeld algorithm. The geometric median provides a centrality measure that is less sensitive to outlier points than the centroid.
The algorithm will iterate until the distance change between successive iterations is less than the supplied tolerance parameter. If this condition has not been met after maxIter iterations, the function will produce an error and exit, unless failIfNotConverged is set to false.
If a tolerance value is not provided, a default tolerance value is 1e-6.
Format:
ST_GeometricMedian(geom: Geometry, tolerance: Double, maxIter: Integer, failIfNotConverged: Boolean)
ST_GeometricMedian(geom: Geometry, tolerance: Double, maxIter: Integer)
ST_GeometricMedian(geom: Geometry, tolerance: Double)
ST_GeometricMedian(geom: Geometry)
Default parameters: tolerance: 1e-6, maxIter: 1000, failIfNotConverged: false
Since: v1.4.1
SQL Example
SELECT ST_GeometricMedian(ST_GeomFromWKT('MULTIPOINT((0 0), (1 1), (2 2), (200 200))'))
Output:
POINT (1.9761550281255005 1.9761550281255005)