How to calculate the average pixel value for each band across multiple raster layers?

9555
10
03-24-2018 02:36 PM
MukunthNatarajan
New Contributor II

I have 20 netcdf files that are essentially data sets of daily precipitation across a region. Each netcdf file is the output of one climate models. Hence each pixel in a netcdf file has 365 bands that represent the precipitation value for each day. I want to calculate the precipitation for each pixel for each day averaged across all the climate models.

I tried converting the raster to point files and extracting multiple values to the point, extracting the data to excel and then averaging them for each raster. I was wondering if there is a more efficient way to do this either using arcpy or model builder.

Suggestions and help would be appreciated!

0 Kudos
10 Replies
DanPatterson_Retired
MVP Emeritus

My examples were just using integers.

Numpy works quite comfortably with floats.

There are several ways to get the raster to array format.  (see scipy for builtins, hdf5 etc

If you have a need to map the result, arcpy.da.NumPyArrayToRaster only requires the 2D raster and a point object denoting the bottom left corner.

The Anaconda distribution of python has pretty well everything you need