I am new to shapely and python. I recently read Splitting Polygon by Linestring in GeoDjango? and below is the resulting answer.
from shapely import wkt
from shapely.ops import linemerge, unary_union, polygonize
POLY = "POLYGON ((34.67491149902344 31.59900710035676, 34.85000610351562 31.59900710035676, 34.85000610351562 31.73867905688433, 34.67491149902344 31.73867905688433, 34.67491149902344 31.59900710035676))"
LINE = "LINESTRING (34.64401245117188 31.63292168314889, 34.80812072753906 31.75911546882192)"
poly = wkt.loads(POLY)
line = wkt.loads(LINE)
merged = linemerge([poly.boundary, line])
borders = unary_union(merged)
polygons = polygonize(borders)
for p in polygons:
print(p)
The print generates two polygon collections.
How do I access the arrays?