Thiago,
Here are more direct approaches:

# generate raster data
r <- raster(ncol=384, nrow=190)
b <- brick(sapply(1:31, function(i) setValues(r, rnorm(ncell(r), i, 3))))

# sum up rain
acc.rain <- sum(b)

# count wet days
wet.days <- sum(b > 0)

or with calc
wet.days <-  calc(b, function(x) sum(x > 0))

Robert

On Tue, Jul 22, 2014 at 1:36 PM, dschneiderch
<dominik.schnei...@colorado.edu> wrote:
> Thiago -
> With regards to your original attempt for part b, I  believe using length()
> instead of sum() will get you what you want.  In this case, sum(x) and
> sum(x[x>1]) are the same assuming you have no values less than 1. Length can
> be used as a proxy for counting how many days rain>1.
>
>
>
>
> --
> View this message in context: 
> http://r-sig-geo.2731867.n2.nabble.com/Count-values-greater-than-in-rasterbrick-layers-tp7586746p7586782.html
> Sent from the R-sig-geo mailing list archive at Nabble.com.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to