geometry.STConvexHull
spatial method STConvexHull (instance.STConvexHull(...))
What changes
- Input
- spatial instance (and arguments)
- Output or change
- geometry
- Return type
- SQL Server return type: geometry CLR return type: SqlGeometry
Syntax at a glance
.STConvexHull ( )
Work example
Use geometry.STConvexHull to return the smallest convex shape enclosing the input.
Use it as a broad summary and keep the source when concavities matter. Keep the geometry type and SRID in the review.
Check your work The convex hull fills the L-shaped notch. Area is in square coordinate units.
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.
DECLARE @shape geometry;
SET @shape = geometry::STGeomFromText(N'POLYGON((0 0, 4 0, 4 1, 1 1, 1 4, 0 4, 0 0))', 0);
SELECT @shape.STConvexHull().STAsText() AS convex_hull, @shape.STConvexHull().STArea() AS hull_area_in_square_coordinate_units,
@shape.STSrid AS source_srid,
@shape.STIsValid() AS source_is_valid;
Open Microsoft Learn for full syntax, permissions, and details for your version.