How do I find all the polygons of a GeoDataframe that contain any point of another GeoDataframe in GeoPandas?
I found a workaround, although I feel like it's not the best solution. My polygons have a unique ID column on which I was able to remove duplicates:
geopandas.sjoin(polygons, points, predicate='contains').drop_duplicates(subset=['UNIQUE_ID'], keep='first')
I have a GeoDataframe of about 3200 polygons, and another GeoDataframe of about 26,000 points. I want to get a third GeoDataframe of only the polygons that contain at least one point. This seems like it should be a simple sjoin, but geopandas.sjoin(polygons, points, predicate='contains') returns a GeoDataframe with more polygons than I started with (and very near the number of input points). Examining this GeoDataframe shows that there seem to be some duplicate polygons, perhaps explaining why I have more polygons than I expected. How do I find only the polygons that contain any point without duplicates?