How split a polygon into n parts of approximately equal size?

  geopandas, python, shapely

Is there a built-in function for dividing a polygon without using another polygon or linestring? Simply by dividing the polygon on itself into n parts of approximately equivalent area.

An idea would be to transform the polygon into a linestrings and to get the interpolation points of these lines for example with:

def get_linesegments(line, n):
    
    points = MultiPoint([line.interpolate(i/n, normalized=True)
                         for i in range(1, n)])
    list_points = [i for i in points]
    
    return list_points

and from these points create linestrings to split the initial polygon. Isn’t there something faster in your opinion?

Source: Python Questions

LEAVE A COMMENT