I'm trying to combine bioclim raster layers to create the following layer.
(Q) = AnnPrec/[(Tmax+Tmin)*(Tmax-Tmin)]*1000
For that, I import a bioclim stack:
envirc = stack("C:/Users/Agus/Dropbox/wiens SL paper/clime.grd")
you can get the stack here: https://www.dropbox.com/sh/n8qfu9cmuowondp/AADcFHTnCqhhoYA43UeckVS-a?dl=0
separate specific layers
AnnPrec=subset( envirc,"bio12")
Tmax=subset( envirc,"bio5")
Tmin=subset( envirc,"bio6")
I could use overlay function , but this seems to work
den=((Tmax+Tmin)*(Tmax-Tmin))*1000
but now, this operation leads me to a constant value, which is incorrect, it # should be a range of values
Q=(AnnPrec/den)
using overlay function gives me the same value
Q=overlay(AnnPrec,Tmax,Tmin, fun=function(x,y,z){return(x/((y+z)*(y-z))*1000)})
What I'm doing wrong?
summary
on your layers so we can be sure your layers aren't constant values. I just tried on three random number rasters and I get a raster with some varying random numbers in. So my money is on a problem related to your data...show(Q)
and you will see the range of values. Because of the odd range of values (mostly very close to zero, but with some outliers, the default legend is not helpful. But seeplot(log(Q))
orplot(Q, zlim=c(-0.0001, 0.0001))
(and fdetsch's answer)