I am having difficulties in
R getting climate data from a
netCDF file into the right format for further analysis. I am working with gridded global data on Standardized Precipitation Index (downloaded from here and want to aggregate the monthly values for each grid-cells to an annual average.
Now the issue is that in the file the data is organised as TXY, where T are the number of months since January 1960 and X and Y are longitude and latitude respectively. As a result, when I load the file into
I get the following dimensions:
class : RasterBrick dimensions : 144, 441, 63504, 58 (nrow, ncol, ncell, nlayers) resolution : 1, 2.5 (x, y) extent : 228, 669, 0, 360 (xmin, xmax, ymin, ymax) coord. ref. : NA data source : data.nc names : X.66.25, X.63.75, X.61.25, X.58.75, X.56.25, X.53.75,... degree_north: -66.25, 76.25 (min, max) varname : aprod
So annoyingly, the monthly observations are on the columns whereas the latitude coordinates are on the layers. Which I don't find very useful and makes processing the data rather difficult.
Therefore I wondered, if there is a way in which I can change the dimensions to a more conventional format? With the data of interest on the layers.