I ran my code successfully last week, cleared the kernel and now it does not work. It must be something simple I'm missing, but I cannot seem to puzzle it out. The purpose of the code is to find all of the polygons inside each of the polygons with a hole. In the data I provided here, there are two polygons with holes in the test_donuts_1.shp file and there are three polygons (including the two polygons with holes) in the test_poly1.shp file.
import geopandas as gpd test_poly1 = gpd.read_file('test_poly1.shp') test_donuts_1 = gpd.read_file('test_donuts_1.shp') intersections_df = gpd.sjoin(test_poly1, test_donuts_1, how='inner', op='within')
This code will run without error for me, but the output is incorrect. It will say that they are only contained within themselves. But I know that if you union the three polygons in test_poly1 together, you get a single polygon. What I mean is that there are two polygons inside one of the test_donuts_1 polygons and there is one polygon inside of the other test_donuts_1 polygon, but this is not caught by sjoin. I have tried setting the crs for both geometries to be the same in my main file even though it is not reflected in the code above.
Can anyone see where I went wrong with this?