Why does the mean of a raster have the value "nan"?

2389
4
04-17-2019 12:42 PM
Lisa-MarieHille
New Contributor II

I used the tool Calculate Statistics on a few raster files. With most of them I got useful values for Min, Max, Mean and Std dev. But for 4 of them the Mean and Std dev. row only show the value "nan" while Min and Max are displayed properly. Do you have any advice how to fix the issue or an idea for another way to get the mean of a raster file?

Thank you very much!

Lisa

0 Kudos
4 Replies
JoeBorgione
MVP Emeritus

nan typically means 'not as number'.  Are the min and the max values real numbers? 

That should just about do it....
0 Kudos
Lisa-MarieHille
New Contributor II

Hello Joe,

thank you for your answer! After I closed and reopened the ArcMap document, the tool worked fine and I got all the results I wished for. Never stop believing in wonders  

JoeBorgione
MVP Emeritus

Voodoo science.  Haven't had one since yesterday where I found a text field set to 255 characters that had 269 characters in it.....

That should just about do it....
0 Kudos
DanPatterson_Retired
MVP Emeritus

Joe is right about nan, 

Calculate Statistics—Data Management toolbox | ArcGIS Desktop 

You need to specify your nodata values in each raster, so check their properties.

If you are still having problems convert your raster to a numpy array using arcpy's 

RasterToNumPyArray

Then you can do thing like

np.nanmean(arr), np.nanstd(arr), np.nanmin(arr)

etcetera

I have a number of blogs on working with rasters and statistics

/blogs/dan_patterson/2018/02/06/cell-statistics-made-easy-raster-data-over-time 

0 Kudos