I have created a raster in ArcGIS Desktop 10 with a large number of holes (NoData) in it.

I want to fill the holes using something like the the following:

rOut = arcpy.sa.Con(arcpy.sa.IsNull(rGround),
arcpy.sa.FocalStatistics(rGround, arcpy.sa.NbrCircle(FillRadius,"CELL"), "MEAN"),

It is desirable to fill the holes by averaging across a circle with a relatively small radius, but a small radius leaves larger holes unfilled, so I need to iterate this operation.

To do that I would like to be able to get the number of NoData values in my raster, once it reaches zero I can stop filling.

1 Answer 1


Actually, it sounds like you want to find the smallest radius necessary to patch the raster. That can be obtained as the maximum of the Euclidean distance to the data cells.

To count the number of NoData cells in any raster, compute an indicator of those cells and sum it. The NoData indicator in ArcGIS is called IsNull (as shown in your sample code): by definition, it returns 1 at NoData cells and 0 elsewhere.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.