Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
Add Comment
Please, Sign In to add comment