So I am building a 30-year average growing degree days raster from the daily min and max temperature for North America. The input data is composed of 60 rasters, 30 tmax, and 30 tmin . Each of those rasters consists of 365 bands (one for each day). The calculation for GDD is fairly simple it is ((tmax-tmin))/2)-10
. The problem is I can't seem to find a way for all the bands and raster to be calculated together.
My initial plan was to stack all tmin rasters and all tmax rasters and subtract them together. But in that case, only the first band (day 1) gets computed. Is there any ways to do the operation without having to extract all bands one by one.
library(raster)
tmax <- stack("C:/gddtmax")
tmin <- stack("C:/gddtmin")
average <- ((tmax-tmin)/2)-10