0

I have a raster brick for daily precipitation data and I need to convert it to monthly data, how would I go about doing this? Each layer is a day and there are 34698 days (i.e. too many to go through manually and create monthly averages by listing mean(raster1, raster 2... etc)

class      : RasterBrick 

dimensions : 64, 58, 3712, 34698  (nrow, ncol, ncell, nlayers)

resolution : 0.44, 0.44  (x, y)

extent     : 12.1, 37.62, -45.54, -17.38  (xmin, xmax, ymin, ymax)

crs        : NA 

source     : C:/Users/teyah/AppData/Local/Temp/RtmpQBzpnO/raster/r_tmp_2020-08-13_121709_23408_66253.grd 

names      : Precipitation.1, Precipitation.2, Precipitation.3, Precipitation.4, Precipitation.5, Precipitation.6, Precipitation.7, Precipitation.8, Precipitation.9, Precipitation.10, Precipitation.11, Precipitation.12, Precipitation.13, Precipitation.14, Precipitation.15, ... 

min values :    0.000000e+00,    0.000000e+00,    0.000000e+00,    0.000000e+00,    0.000000e+00,    0.000000e+00,    0.000000e+00,    0.000000e+00,    0.000000e+00,     0.000000e+00,     0.000000e+00,     0.000000e+00,     0.000000e+00,     0.000000e+00,     0.000000e+00, ... 

max values :    6.533941e-04,    1.833772e-04,    8.561218e-04,    1.070062e-03,    7.177751e-04,    6.058318e-04,    5.470571e-04,    1.588907e-03,    1.674356e-03,     1.091221e-03,     5.895557e-04,     3.984022e-04,     4.418955e-04,     3.041818e-04,     2.085147e-04, ... 
1
  • 1
    Take a look at the rts package. There are specific functions for aggregating raster timeseries data to different summary periods. Aug 18, 2020 at 14:08

1 Answer 1

1

Use zApply with by=as.yearmon. as.yearmon is available in the zoo package.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.