0
votes

I have a rasterbrick containing daily time series and temperature data (summarised below). How can I create a single raster layer from this rasterbrick showing average number of days (per year) where temperature is <0?

class      : RasterBrick 
dimensions : 201, 464, 93264, 5479  (nrow, ncol, ncell, nlayers)
resolution : 0.25, 0.25  (x, y)
extent     : -40.5, 75.5, 25.25, 75.5  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 
source     : F:/new maxent/tn_ens_spread_0.25deg_reg_1980-1994_v21.0e.nc 
names      : X1980.01.01, X1980.01.02, X1980.01.03, X1980.01.04, X1980.01.05, X1980.01.06, X1980.01.07, X1980.01.08, X1980.01.09, X1980.01.10, X1980.01.11, X1980.01.12, X1980.01.13, X1980.01.14, X1980.01.15, ... 
Date       : 1980-01-01, 1994-12-31 (min, max)
varname    : tn 
1

1 Answers

0
votes

Here is a minimal, self-contained, reproducible example

library(raster)
b <- brick(system.file("external/rlogo.grd", package="raster"))
x <- b - 100

To get, for each cell, the proportion of layers that have a value below zero, you can do

r <- mean(x < 0)