ST_ConvexHull¶
Introduction: Returns the smallest convex region containing the input. Geometry hulls are
computed in the coordinate plane. Geography hulls are computed on the sphere, with geodesic
edges.
Format:
ST_ConvexHull (A: Geometry)
ST_ConvexHull (A: Geography)
Return type: Geometry or Geography, matching the input type
Since: v1.5.0 (Geometry), v1.9.1 (Geography)
For Geography, one unique point produces a Point, collinear points produce a LineString,
and all other non-empty inputs produce a spherical Polygon. Empty inputs retain their type and
SRID. A hull covering the full sphere is not supported.
Geometry example:
SELECT ST_ConvexHull(ST_GeomFromText('POLYGON((175 150, 20 40, 50 60, 125 100, 175 150))'))
Output:
POLYGON ((20 40, 175 150, 125 100, 20 40))
Geography example:
SELECT ST_GeometryType(
ST_ConvexHull(
ST_GeogFromWKT(
'MULTIPOINT ((170 -10), (170 10), (-170 10), (-170 -10))',
4326
)
)
)
Output:
ST_Polygon