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

SciPy · Class

spatial.Voronoi

Constructs an N-dimensional Voronoi diagram from point coordinates. Options support furthest-site diagrams, incremental construction, and custom Qhull settings.

Since
0.12.0

How it works

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.

Syntax

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

Parameters

NameTypeDescription
pointsndarray of floats, shape (npoints, ndim)Coordinates of points to construct a Voronoi diagram from; an array of floats with shape (npoints, ndim).
furthest_sitebool, optional; default FalseWhether to compute a furthest-site Voronoi diagram.
incrementalbool, optional; default FalseAllow adding new points incrementally; this uses additional resources.
qhull_optionsstr, optionalAdditional options passed to Qhull.

Returns

A Voronoi object containing the computed diagram and its geometric/index data.

Key points

  • The class represents Voronoi diagrams in any number of dimensions.
  • points contains the coordinates used to construct the diagram.
  • furthest_site switches to furthest-site construction when set to True.
  • incremental enables incremental point insertion.
  • qhull_options forwards caller-supplied options to Qhull.
  • Qhull performs the underlying Voronoi computation.

Common mistakes

  • When incremental is enabled, the default Qhull configuration excludes Qz.
  • Enabling incremental construction requires additional resources.

Example: Construct a Voronoi diagram

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.

When to use it

Nearest-site spatial partitioning

Partitioning 2D or higher-dimensional space according to the closest input site.

Furthest-site analysis

Generating a diagram based on distances from sites in the opposite direction.

Incremental construction

Updating a diagram as additional points arrive.

Geometric feature extraction

Accessing vertices, regions, and point-to-region relationships for downstream geometry processing.

Interview questions

QWhat does scipy.spatial.Voronoi compute, and what input shape does it expect?

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.

QWhat is the purpose of furthest_site?

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.

QHow are Qhull options selected?

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_2d
  • scipy.spatial.Delaunay
  • scipy.spatial.ConvexHull
  • scipy.spatial.KDTree

Source: Voronoi. Checked 2026-10-15.