# Making polygon for every point in set using Voronoi diagram

I'm trying to make polygons from points, where each point will be represented by one polygon. I tried using Voronois, but the results are incomplete. While I more or less understand where this incompleteness comes from, I don't know how to solve such problem.

I also have another, bigger polygon that is an area containing all the points. At the end, I want all the small Voronois to cover 100% of this big polygon area. In other words:

I want all the empty white spaces filled with voronois/polygons and I want each voronoi/polygon to contain just one point.

My code:

``````from scipy.spatial import Voronoi
import numpy as np
import shapely
import geopandas as gpd

#pointset is geodataframe with points, region is geodataframe with big
#polygon I want to fill with voronois

x = pointset.geometry.x.values
y = pointset.geometry.y.values
coords = np.vstack((x, y)).T
vor = Voronoi(coords)

lines = [shapely.geometry.LineString(vor.vertices[line]) for line in
vor.ridge_vertices if -1 not in line]
polys = shapely.ops.polygonize(lines)
voronois = gpd.GeoDataFrame(geometry=gpd.GeoSeries(polys))

voronois = gpd.overlay(voronois, region)
``````

Basically, I just use Voronoi and then intersect the result with my region polygon. Any advice about how to make result complete?

• Buffer the larger polygon (by distance large enough not to interfere), make it into points and use them within Voronoi. then clip by polygon. The issue is caused by ridges going to infinity. It is implemented in here docs.momepy.org/en/latest/generated/… so you can peek into the code how exactly. Oct 2, 2019 at 16:13
• See this comment to address those boundaries: stackoverflow.com/questions/23901943/… Aug 11, 2020 at 13:12