Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

SciPy · Class

spatial.ConvexHull

ConvexHull computes the convex hull enclosing points in N-dimensional space. It returns an object with hull indices, facets, geometric measures, and optional incremental-update methods.

Since
0.12.0

How it works

Constructing ConvexHull with an array of point coordinates runs Qhull to determine the enclosing convex polytope. The resulting object exposes the input-point indices defining the boundary, geometric measures, simplex facets, and optional incremental-update operations.

Syntax

scipy.spatial.ConvexHull(points, incremental=False, qhull_options=None)

Parameters

NameTypeDescription
pointsndarrayCoordinates of points to construct a convex hull from; an array of floats with shape (npoints, ndim).
incrementalbool, optionalWhether to allow adding new points incrementally; this uses additional resources.
qhull_optionsstr, optionalExtra options passed to Qhull. The default is Qx when ndim > 4 and empty otherwise; Qt is always enabled.

Returns

A ConvexHull object containing the computed hull and its geometric properties.

Key points

  • The class computes an enclosing convex hull for point sets in arbitrary dimensional spaces.
  • Each row of points supplies one coordinate vector, with the second dimension determining the ambient space.
  • Use qhull_options to forward specialized algorithm settings to the underlying Qhull library.
  • SciPy delegates the hull calculation to Qhull rather than implementing the geometric algorithm itself.
  • With incremental construction enabled, add_points incorporates another batch into the existing hull.
  • close finalizes an incremental hull after point updates are complete.
  • The documentation identifies SciPy 0.12.0 as the introduction version for ConvexHull.

Common mistakes

  • The triangulation option Qt cannot be disabled through qhull_options because SciPy enables it for every hull.
  • Setting incremental=True supports later point insertion but consumes extra resources compared with one-shot construction.
  • The coplanar attribute is unavailable unless the Qhull coplanar-point option Qc is included.

Example: Compute a 2-D convex hull

import numpy as np
from scipy.spatial import ConvexHull

points = np.array([
    [0, 0], [2, 0], [2, 2], [0, 2], [1, 1]
])
hull = ConvexHull(points)
print(hull.vertices)
print(hull.area)
print(hull.volume)

Builds a two-dimensional hull and prints its boundary-point indices, perimeter, and enclosed area.

When to use it

Boundary and size analysis

Summarize a point cloud by its outer boundary and calculate its geometric size.

Incremental point ingestion

Maintain a hull while batches of observations arrive, avoiding an immediate full reconstruction.

Geometric feature extraction

Extract boundary facets and point indices for downstream computational-geometry operations.

Interview questions

QWhat does scipy.spatial.ConvexHull represent?

ConvexHull computes the convex hull of points in N dimensions using Qhull. The input is an array shaped (npoints, ndim), and the returned object stores the hull geometry and related measurements.

Follow-up: How would you preserve boundary points that lie on a facet but are not vertices? Include Qc in qhull_options and inspect the coplanar attribute.

QExplain the constructor parameters.

The points parameter is a floating-point array whose rows are coordinates. incremental enables adding points later, while qhull_options passes additional controls to Qhull; the default is Qx above four dimensions and empty otherwise.

Follow-up: What fixed Qhull behavior should be remembered when customizing options? Qt remains enabled regardless of qhull_options.

QWhich result attributes are useful for geometric analysis?

In two dimensions, area is the perimeter and volume is the enclosed area; in higher dimensions, they correspond to the hull's surface measure and content, respectively. The vertices attribute gives the input indices of hull vertices.

Follow-up: How can new data be incorporated without reconstructing immediately? Construct with incremental=True, call add_points, and call close when incremental processing is finished.

  • scipy.spatial.Delaunay
  • scipy.spatial.Voronoi
  • scipy.spatial.QhullError
  • ConvexHull.add_points
  • ConvexHull.close

Source: scipy.spatial.ConvexHull — SciPy v1.13.0 Manual. Checked 2026-10-15.