[Python] Iterate over Polygon vertices as Points with Shapely?

Discussão em 'Python' iniciado por Stack, Julho 6, 2025.

  1. Stack

    Stack Membro Participativo

    Shapely's Polygon and LinearRing are not iterable (any longer, if I remember the history correctly). I often need to iterate over their vertices as Point objects (not tuple), and my current solution seems cumbersome. Is there a simpler way than this, without NumPy magic?

    poly = Polygon([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)])
    vertices = MultiPoint(np.column_stack(poly.exterior.coords.xy))

    for p in vertices.geoms:
    print(p)

    Continue reading...

Compartilhe esta Página