Skip to content

ST_ConvexHull

Returns the Convex Hull of a geometry or geography.

Usage

geometry ST_ConvexHull(geom: geometry)
geography ST_ConvexHull(geog: geography)

Arguments

  • geog (geography): Input geography
  • geom (geometry): Input geometry

Description

Returns the smallest convex polygon that encloses all points in the input geometry.

Examples

SELECT ST_ConvexHull(
  ST_GeomFromText('MULTIPOINT ((0 0), (0 1), (1 0))')
);
┌──────────────────────────────────────────────────────────────────────────┐
│ st_convexhull(st_geomfromtext(Utf8("MULTIPOINT ((0 0), (0 1), (1 0))"))) │
│                                 geometry                                 │
╞══════════════════════════════════════════════════════════════════════════╡
│ POLYGON((0 0,0 1,1 0,0 0))                                               │
└──────────────────────────────────────────────────────────────────────────┘
SELECT ST_ConvexHull(
  ST_GeogFromWKT('MULTIPOINT ((0 0), (0 1), (1 0))')
);
┌─────────────────────────────────────────────────────────────────────────┐
│ st_convexhull(st_geogfromwkt(Utf8("MULTIPOINT ((0 0), (0 1), (1 0))"))) │
│                                geography                                │
╞═════════════════════════════════════════════════════════════════════════╡
│ POLYGON((0 0,1 0,0 1,0 0))                                              │
└─────────────────────────────────────────────────────────────────────────┘