# Making polygon for every point in set using voronois?

I'm trying to make polygons from points, were 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 uncompletness comes from, I don't know how can I solve such problem.

I also have another, bigger polygon that is an area containing all the points. In 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)
``````

So basicly 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. – martinfleis Oct 2 at 16:13