ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Geometry Namespace / IGeometryEngine Interface / ConvexHull Method
The geometry to create a convex hull of.
Example

In This Topic
    ConvexHull Method (IGeometryEngine)
    In This Topic
    Constructs the convex hull of the geometry.
    Syntax
    Function ConvexHull( _
       ByVal geometry As Geometry _
    ) As Geometry
    Geometry ConvexHull( 
       Geometry geometry
    )

    Parameters

    geometry
    The geometry to create a convex hull of.

    Return Value

    A polygon that represents the convex hull of the input geometry. If the input geometry is empty, then an empty polygon is returned.
    Exceptions
    ExceptionDescription
    Geometry is null.
    The method is not implemented for GeometryBag.
    Remarks
    The convex hull of a geometry is the minimal bounding polygon such that all outer angles are convex. The ConvexHull of a point is the point itself.

    GeometryEngine ConvexHull

    Example
    Determine convex hull
    {
        //
        // convex hull around a point - returns a point
        //
    
        MapPoint pt = MapPointBuilderEx.CreateMapPoint(2.0, 2.0);
        Geometry hull = GeometryEngine.Instance.ConvexHull(pt);
        MapPoint hullPt = hull as MapPoint;
        // nullPt.X = 2
        // hullPt.Y = 2
    
    
        List<MapPoint> list =
        [
          MapPointBuilderEx.CreateMapPoint(1.0, 1.0),
      MapPointBuilderEx.CreateMapPoint(1.0, 2.0),
      MapPointBuilderEx.CreateMapPoint(2.0, 2.0),
      MapPointBuilderEx.CreateMapPoint(2.0, 1.0),
    ];
    
        //
        // convex hull around a multipoint - returns a polygon
        //
    
        // build a multiPoint
        Multipoint multiPoint = MultipointBuilderEx.CreateMultipoint(list);
    
        hull = GeometryEngine.Instance.ConvexHull(multiPoint);
        Polygon hullPoly = hull as Polygon;
        // hullPoly.Area = 1
        // hullPoly.PointCount = 5
    
        // 
        // convex hull around a line - returns a polyline or polygon
        // 
    
        List<MapPoint> polylineList = [MapPointBuilderEx.CreateMapPoint(1.0, 1.0), MapPointBuilderEx.CreateMapPoint(2.0, 2.0)];
    
        // 2 point straight line
        polyline = PolylineBuilderEx.CreatePolyline(polylineList);
        hull = GeometryEngine.Instance.ConvexHull(polyline);
        Polyline hullPolyline = hull as Polyline;
        // hullPolyline.Length = Math.Sqrt(2)
        // hullPolyline.PointCount = 2
    
        // 3 point angular line
        polylineList.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0));
        polyline = PolylineBuilderEx.CreatePolyline(polylineList);
        hull = GeometryEngine.Instance.ConvexHull(polyline);
        hullPoly = hull as Polygon;
        // hullPoly.Length = 2 + Math.Sqrt(2)
        // hullPoly.Area = 0.5
        // hullPoly.PointCount = 4
    
        //
        // convex hull around a polygon - returns a polygon
        //
    
        // simple polygon
        Polygon poly = PolygonBuilderEx.CreatePolygon(list);
        hull = GeometryEngine.Instance.ConvexHull(poly);
        hullPoly = hull as Polygon;
    
        // hullPoly.Length = 4.0
        // hullPoly.Area = 1.0
        // hullPoly.PointCount = 5
    
        // polygon with concave angles
        List<MapPoint> funkyList =
        [
          MapPointBuilderEx.CreateMapPoint(1.0, 1.0),
      MapPointBuilderEx.CreateMapPoint(1.5, 1.5),
      MapPointBuilderEx.CreateMapPoint(1.0, 2.0),
      MapPointBuilderEx.CreateMapPoint(2.0, 2.0),
      MapPointBuilderEx.CreateMapPoint(1.5, 1.5),
      MapPointBuilderEx.CreateMapPoint(2.0, 1.0),
      MapPointBuilderEx.CreateMapPoint(1.0, 1.0),
    ];
    
        Polygon funkyPoly = PolygonBuilderEx.CreatePolygon(funkyList);
        hull = GeometryEngine.Instance.ConvexHull(funkyPoly);
        hullPoly = hull as Polygon;
        // hullPoly.Length = 4.0
        // hullPoly.Area = 1.0
        // hullPoly.PointCount = 5
        // hullPoly.Points[0] = 1.0, 1.0
        // hullPoly.Points[1] = 1.0, 2.0
        // hullPoly.Points[2] = 2.0, 2.0
        // hullPoly.Points[3] = 2.0, 1.0
        // hullPoly.Points[4] = 1.0, 1.0
      }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also