Skip to main content
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. ST_GeometricMedian 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.

Signatures

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)

Parameters

geom
Geometry
required
The input geometry.
tolerance
Double
The distance tolerance.
maxIter
Integer
The max iter value.
failIfNotConverged
Boolean
The fail if not converged value.

Return type

The resulting geometry.

Example

SELECT ST_GeometricMedian(ST_GeomFromWKT('MULTIPOINT((0 0), (1 1), (2 2), (200 200))'))
POINT (1.9761550281255005 1.9761550281255005)