tiggs03

Raster calculations when NaNs are present

Discussion created by tiggs03 on Apr 6, 2012
I have 10 raster grids and need to generate a summary raster that is the mean of all 10. Unfortunately, there are some NaNs (which I guess No Data are actually coded as -9999) in a couple of the rasters, and when I simply use the raster calculator, it only evaluates where data is available in all grids. So there are gaps in the summary "mean" raster. I'd rather that the mean is generated by ignoring where there are NaNs. For instance, if there is a gap in Grid 1, the mean for that gap area is just calculated from Grids 2-10. Is there code to do this in Python? I know there is something similar in Matlab (the function nanmean) but I don't want to go through the headache of getting the data into Matlab structure, to be honest.

Thanks!

Outcomes