[GIS] Counting NoData values in raster using ArcGIS Desktop

arcgis-10.0arcgis-desktopraster

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"),
rGround)

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.

Best Answer

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.

Related Question