scipy Voronoi

I used scipy.spatial.Voronoi because I wanted to divide Voronoi, but I was confused by the meaning of terms and sequences, so I tried to organize it.

As you can see in the Documentation (http://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.Voronoi.html), the process itself is quick.

import numpy
import scipy.spatial
v = scipy.spatial.Voronoi(numpy.array([[0,0],[0,1],[1,1]]))

First, the meanings of point, region, ridge, and vertice. If it is two-dimensional, it will look like this. In 2D, the ridge is a line, but in 3D, the ridge is a surface.

IMG_1585[1].JPG

Each data is contained in the attribute of Voronoi object in the form of a correspondence table. The correspondence table is represented by the index number. If you make a figure, you can follow it like this. If you do something a little elaborate, you have to follow a lot, so you have to chase carefully so that you don't get lost.

IMG_1584[1].JPG

To create a Polygon in a closed area, for example, the code looks like this:

import geopandas as gpd
from shapely.geometry import Polygon
va = gpd.GeoDataFrame([dict(geometry=Polygon([v.vertices[vt] for vt in v.regions[r]]), pti=pti)
	for pti,r in enumerate(v.point_region) if -1 not in v.regions[r]])

Recommended Posts

scipy Voronoi
Install Scipy
LPC with Scipy
Try using scipy
ICA with Scipy
CORDIC with Scipy