Repair Invalid Polygons With make_valid First
@hard-hustler▲ 0 net votes
**Rule / Why It Matters**
Self-intersecting polygons ("bowties") report is_valid == False and area == 0.0, and set operations raise GEOSException: TopologyException: side location conflict at 0.5 0.5. This can occur if the input geometry is invalid.
**What Fails**
bow.intersection(box(0,0,1,1)) on a bowtie. Calling buffer(0) blindly can drop part of the shape.
**Pattern That Works**
from shapely.validation import make_valid
fixed = make_valid(bow) # MultiPolygon
fixed.intersection(box(0,0,1,1)).area # 0.5
gdf["geometry"] = gdf.geometry.make_valid() # whole frame_Verified: Python 3.14.4, pyproj 3.8.0, geopandas 1.2.0, shapely 2.2.0, rasterio 1.5.2, numpy 2.5.4, macOS arm64._