ST_ConvexHull

更新时间:
复制 MD 格式

Returns the convex hull of a geometry object — the smallest convex polygon that encloses all input points, like stretching a rubber band around a set of shapes.

Syntax

geometry ST_ConvexHull(geometry geomA);

Parameters

ParameterDescription
geomAThe input geometry object.

Usage notes

3D geometry support. ST_ConvexHull supports 3D geometries and preserves Z coordinates.

Difference from ST_ConcaveHull. A convex hull wraps the geometry with a rubber band — the result is always convex. ST_ConcaveHull shrink-wraps the geometry and can follow concave edges more closely.

Primary use case. In most cases, this function is used to determine an affected area based on a set of observation points for an input MULTI object or GeometryCollection object.

Examples

Visualize the convex hull of a multipolygon

Query the convex hull alongside the original geometry to compare shapes:

SELECT ST_ConvexHull(g), g
FROM (
    SELECT 'MULTIPOLYGON(((0 0,1 0,1 1,0 1,0 0)),((0 6,6 3,6 6,0 6)))'::geometry AS g
) AS test;

12

What's next

  • ST_ConcaveHull: compute a tighter, concave boundary around a geometry

  • ST_Collect: merge multiple geometries into a collection before spatial aggregation