Nearest-site spatial partitioning
Partitioning 2D or higher-dimensional space according to the closest input site.
SciPy · Class
Constructs an N-dimensional Voronoi diagram from point coordinates. Options support furthest-site diagrams, incremental construction, and custom Qhull settings.
Voronoi constructs an N-dimensional Voronoi diagram from point coordinates using Qhull. The returned object exposes the computed geometry through arrays and index mappings, while optional settings enable furthest-site diagrams, incremental insertion, and custom Qhull behavior.
scipy.spatial.Voronoi(points, furthest_site=False, incremental=False, qhull_options=None)| Name | Type | Description |
|---|---|---|
points | ndarray of floats, shape (npoints, ndim) | Coordinates of points to construct a Voronoi diagram from; an array of floats with shape (npoints, ndim). |
furthest_site | bool, optional; default False | Whether to compute a furthest-site Voronoi diagram. |
incremental | bool, optional; default False | Allow adding new points incrementally; this uses additional resources. |
qhull_options | str, optional | Additional options passed to Qhull. |
A Voronoi object containing the computed diagram and its geometric/index data.
import numpy as np
from scipy.spatial import Voronoi
points = np.array([[0, 0], [1, 0], [0, 1], [1, 1]])
vor = Voronoi(points)
print(vor.vertices)
print(vor.regions)
print(vor.point_region)Builds a two-dimensional Voronoi diagram and prints its vertices, region index lists, and point-to-region mapping.
Partitioning 2D or higher-dimensional space according to the closest input site.
Generating a diagram based on distances from sites in the opposite direction.
Updating a diagram as additional points arrive.
Accessing vertices, regions, and point-to-region relationships for downstream geometry processing.
Voronoi accepts an array shaped (npoints, ndim) and computes an N-dimensional Voronoi diagram. The calculation is performed through the Qhull library.
Follow-up: How would you request a furthest-site diagram? Pass furthest_site=True when constructing the object.
The furthest_site option selects whether the diagram is based on furthest sites rather than the default nearest-site construction. Its default is False.
Follow-up: What other construction mode changes resource usage? incremental=True allows points to be added incrementally and consumes additional resources.
qhull_options supplies extra options to Qhull. If omitted, SciPy uses “Qbb Qc Qz Qx” when ndim is greater than four and “Qbb Qc Qz” otherwise; incremental mode omits Qz.
Follow-up: Why might a caller set this option? To tune Qhull behavior for a particular input or numerical issue, while following Qhull's option rules.
scipy.spatial.voronoi_plot_2dscipy.spatial.Delaunayscipy.spatial.ConvexHullscipy.spatial.KDTree