I want to find the number of rows and columns possible inside a shapely polygon. The purpose is I need to create circles inside each cell. Also there will be a value for radius and distance between these circles.
import numpy as np
from shapely.geometry import Polygon
def generate_circles(pointsdata, radius, distance):
points_data = np.array(pointsdata['DataPoints']).astype(float)
x_coords, y_coords = points_data[:, 0], points_data[:, 1]
shapely_polygon = Polygon(list(zip(x_coords, y_coords)))
if shapely_polygon.is_empty or not shapely_polygon.exterior:
pass
else :
#I want to find number of rows and columns possible
#inside this polygon considering the radius and distance
pointsdata = { 'NumberofDataPoints': 8, "DataPoints": [ [0, 0], [1, 0.5], [1.5, 1.5], [1, 2.5], [0, 3], [-1, 2.5], [-1.5, 1.5], [-1, 0.5] ] }
radius = 1.5
distance = 2
generate_circles(pointsdata,radius,distance)
How can i find number of rows and columns possible?
IIUC, you're trying to do some sort of Circle Packing.
If so, you can try the option below (inspired by
set_gridfrom @Pierrick Rambaud) :