# Calculate average value from netcdf

I have precipitation data from NOAA in a NetCDF format. I imported that into ArcGIS as a raster layer. Now I see that I can only get the precipitation value for one year at a time.

I need to calculate the annual average precipitation for the decade (1980-1990).

Is there any way to do this?

I am very new to GIS and don't know how to use Python. I have dabbled with the ModelBuilder a bit.

Assuming that you can get each year as a separate raster, do so. Then use ArcToolbox > Spatial Analyst > Local > Cell Statistics to compute a new raster whose cell values are the mean of the precipitation values at corresponding locations in all the other one-year rasters.

There are several ways of doing this, and probably by now you have already solved it. In case you haven't, I would make use of GDAL.

GDAL

Just open a terminal on a machine that has gdal installed, and type in:

gdal_calc.py -A yourNOAAfile.nc --A_band=1 -B C:/yourNOAAfile.nc --B_band=2 -C yourNOAAfile.nc --C_band=3 --outfile=Avergage.nc --calc="((A+B+C)/3)"

ArcMap

In case you are not familiar with commandline tools and prefer a more ArcGIS solution, have a look here. Basically you either make use of the raster calculator or the cell statistics function.

QGIS

And the QGIS alternative with a very sweet tutorial by Gregory Giuliani.

In QGIS, you can use Mesh Calculator (main menu > Mesh > Mesh calculator). The expression you need is average (aggr).

You can filter Start and End time (temporal filter) or using Mask Layer or an extent to limit the calculation to a certain geographic area:

• Hi, I have tried this several times, it is not working, the result the program is giving is super strange, the values are getting negative. Looks like it is not really taking the average of all "bands". Commented Sep 8, 2022 at 16:02

I think you solved it by now, but to benefit other users. I faced the same problem but solved it following this approach:

First go to multidimension tools > make NetCDF raster layer, in the interface (see pic) select the suitable inputs but pay attention that you need to put 'time' in the 'band dimension' not band values. You will get one raster layer that might not show your data and might not look right, but that's okay proceed to step two

Second, go to SDM toolbox (if you don't have it you can download it freely just google it) > Basic tools> Raster tools > multiband netcdf to separate rasters and you should get all your separate rasters. The tool might exist in other toolboxes that you might have so check.

Note that you can't put the NetCDF immediately in the second tool as you must first convert your NetCDF file to an ArcGIS friendly format using the first tool.