简体   繁体   中英

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.

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 (eg, see discussion here ). So it is expected that scipy passes this error through.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM