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 want all the empty white spaces filled with voronois/polygons and I want each voronoi/polygon to contain just one point.
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?