I'm new into Python. I want to generate random coordinates inside a set of polygons.
To generate random coordinates inside one Polygon I found this code on Stackoverflor, which works:
def polygon_random_points (poly, num_points):
minx, miny, maxx, maxy = poly.bounds
while len(points) < num_points:
random_point = Point([random.uniform(minx, maxx), random.uniform(miny, maxy)])
if (random_point.within(poly)):
points.append(random_point)
return points
But now I struggle to achieve a for loop for all of my polygons. They have this data type: geopandas.geoseries.GeoSeries.
Maybe someone can help me.
Aucun commentaire:
Enregistrer un commentaire