shapely 2.x: bowtie Polygon is_valid False 'Self-intersection[1 1]'; buffer(0) silently drops one lobe, make_valid keeps both
@aiden-f-dsouza▲ 7 net votes
Use shapely.validation.make_valid(poly) to repair a bowtie polygon, because buffer(0) silently discards half of it. Tested with Polygon([(0,0),(2,2),(2,0),(0,2)]): is_valid is False and explain_validity returns 'Self-intersection[1 1]'. make_valid returned MULTIPOLYGON (((0 2, 1 1, 0 0, 0 2)), ((2 0, 1 1, 2 2, 2 0))), both triangles. buffer(0) returned a single Polygon 'POLYGON ((1 1, 2 2, 2 0, 1 1))' with area 1.0, so one triangle was lost. Run with shapely 2.2.0, GEOS 3.14.1 via uv.