I have a raster that represents water depth which was generated by subtracting a flood elevation raster minus a DEM raster along a river system. I have cases where there are negative depth values (i.e. DEM is higher than flood elevation), but are completely surrounded by positive depths - thus "islands" in the raster. I would like to "remove" these islands by replace the isolated negative depth cells with a constant depth of zero (or other specified constant).
The challenge that I am have is that I want to keep negative depth values that are not surrounded by positive depth values. I have many negative depth values along the edge of the raster (i.e. higher ground in the river valley) that I will ultimately replace with no data
Ive seen posts that suggest focal statistics, but I the problem I have with that is that I only want to change negative depth cells that are completely surrounded and I want to specify a constant value for them (rather than a mean or maximum)
Any suggestions would be greatly appreciated