geometry::ConvexHullAggregate
spatial aggregate ConvexHullAggregate
What changes
- Input
- spatial values of each group
- Output or change
- one geometry/geography per group
- Return type
- SQL Server return type: geometry
Syntax at a glance
ConvexHullAggregate ( geometry_operand )
Work example
Use geometry.ConvexHullAggregate to compute one convex hull around a group of shapes.
Choose the report group and compare the hull with source outlines. Keep the geometry type and SRID in the review.
Check your work The hull includes the gap between polygons in the SRID 0 planar frame.
Practice SQL
Open in SQL FlowOpen the SQL for a walkthrough. Run the example in SQL Server to check its result.
-- Planar geometry. SRID 0 coordinates here are synthetic units, not metres.
WITH shapes (shape) AS
(
SELECT geometry::STGeomFromText(N'POLYGON((0 0, 2 0, 2 2, 0 2, 0 0))', 0) AS shape
UNION ALL
SELECT geometry::STGeomFromText(N'POLYGON((4 0, 6 0, 6 2, 4 2, 4 0))', 0) AS shape
)
SELECT geometry::ConvexHullAggregate(shape).STAsText() AS group_hull,
geometry::ConvexHullAggregate(shape).STSrid AS result_srid,
geometry::ConvexHullAggregate(shape).STIsValid() AS result_is_valid
FROM shapes;
Open Microsoft Learn for full syntax, permissions, and details for your version.