Skip to main content

ST_ConvexHull

Returns the smallest convex polygon that contains all points of a geometry.

Syntax

ST_ConvexHull(geometry)

Parameters

ParameterTypeDescription
geometryGeometryInput geometry

Returns

TypeDescription
Binary (WKB)Convex hull as WKB with geoarrow.wkb metadata

Examples

Convex Hull of MultiPoint

SELECT ST_ConvexHull(ST_GeomFromText('MULTIPOINT(0 0, 4 0, 2 3)'));
-- Returns: triangle polygon

Convex Hull of Concave Polygon

SELECT ST_ConvexHull(ST_GeomFromText('POLYGON((0 0, 2 0, 2 1, 1 1, 1 2, 0 2, 0 0))'));
-- Returns: POLYGON((0 0, 2 0, 2 1, 1 2, 0 2, 0 0)) - fills in the concave corner

Calculate Convex Hull Area Ratio

SELECT id,
ST_Area(geom) as original_area,
ST_Area(ST_ConvexHull(geom)) as hull_area,
ST_Area(geom) / ST_Area(ST_ConvexHull(geom)) as convexity
FROM parcels;

Combined Convex Hull

SELECT ST_ConvexHull(ST_Union(geom)) as combined_hull
FROM points;

Notes

  • Think of it as stretching a rubber band around the geometry
  • For convex polygons, returns the same polygon
  • For concave polygons, fills in the "indentations"
  • Useful for computing coverage areas and simplifying complex shapes
  • Always returns a valid geometry

See Also