Title: Counting NoData values in raster using ArcGIS Desktop?
Tags: arcgis-desktop;arcgis-10.0;raster
Question: 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.


Here is another 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.

{'source': 'StackExchangeDataset', 'subset': 'gis.stackexchange.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2011:00:01/31/11', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<arcgis-desktop><arcgis-10.0><raster>', 'Title': 'Counting NoData values in raster using ArcGIS Desktop?', 'ViewCount': 2605, 'id': 5675, 'user_AboutMe': None, 'user_AccountId': None, 'user_DisplayName': None, 'user_Reputation': None, 'user_Views': None, 'user_id': None}}