The error "TopologicalError: The operation 'GEOSIntersection_r' could not be performed. Likely cause is invalidity of the geometry <shapely.geometry.polygon.Polygon object at 0x0000025FB05BDA80>" keeps popping up whenever I try to run my code with certain shapefiles. This only happens with some shapefiles, though-- sometimes it'll work just fine. I just can't figure out how to fix the geometries that are giving me problems.
Here's my code:
import geopandas as gpd
import maup
bg = gpd.read_file("co_BG.zip")
precincts = gpd.read_file("co_2020.zip")
precincts = precincts.to_crs(epsg=2163)
bg = bg.to_crs(epsg=2163)
pieces = maup.intersections(bg, precincts, area_cutoff=0)
I've tried using .buffer(0) and make_valid from shapely but I'm not sure if I did it right since I'm pretty new to this stuff. I saw that someone asked a similar question once but I read the answers and tried them but it still didn't work so either something different is going on or I did it wrong.