I have created a shapefile from raster. The shapefile was generated using contours detection. I am in the process of automating feature detection using Python and open source libraries such as shapely, fiona, ogr. The problem I am having is that the shapefile generated works well in detecting features small in size but when it tries to detect large features it also detects features inside the large feature. This results in feature inside a feature problem.
I have been trying to implement polygon inside a polygon implementation but have not been able to implement it successfully. I am thinking of finding a way in which this issue of feature inside a feature gets removed during the process of making the shapefile at the very beginning (raster to shapefile conversion). Need some suggestions on how to proceed on this issue.
The red highlighted area is the region I am interested in and everything inside it needs to be removed.