Baz
Baz

Reputation: 13135

Not enough points(2) supplied to Voronoi

I'm trying to compute a Voronoi Diagram for only two points:

from scipy.spatial import Voronoi
vor = Voronoi([[0, 0], [0, 1]])

but get the following error:

    vor = Voronoi(points)
  File "qhull.pyx", line 2518, in scipy.spatial.qhull.Voronoi.__init__
  File "qhull.pyx", line 354, in scipy.spatial.qhull._Qhull.__init__
scipy.spatial.qhull.QhullError: QH6214 qhull input error: not enough points(2) to construct initial simplex (need 4)

While executing:  | qhull v Qc Qz Qbb
Options selected for Qhull 2015.2.r 2016/01/18:
  run-id 12883022  voronoi  Qcoplanar-keep  Qz-infinity-point  Qbbound-last
  _pre-merge  _zero-centrum  Qinterior-keep

Is this expected behaviour? I'm splitting MultiPolygons based on a set of points contained within them, and in one of the cases there are only two points.

Upvotes: 2

Views: 1130

Answers (1)

Alex
Alex

Reputation: 1132

This doesn't seem to be explicitly documented. But the underlying code (qhull) is building the Voronoi diagram from the Delaunay triangulation. You will need at least three non-colinear points to get a valid triangulation, and thus a successful Voronoi diagram. This is an expected requirement of qhull: you need at least dimension plus one points to get any triangulation (e.g., see discussion here). So it is expected that scipy passes this error through.

Upvotes: 2

Related Questions