I would like to get all the bioclimatic variables of future scenarios for modeling the distribution of species. So I run the "biovars" function in the "dismo" packages using three variables from the worldclim database, and I have a 12-layer RasterBrick:
>prec<-stack(paste(getwd(),"/prec_2080/wc_2_5m_HADCM3_B2a_2080_prec_",1:12,".bil",sep=""))
>tmin<-stack(paste(getwd(),"/tmin_2080/wc_2_5m_HADCM3_B2a_2080_tmin_",1:12,".bil",sep=""))
>tmax<-stack(paste(getwd(),"/tmax_2080/wc_2_5m_HADCM3_B2a_2080_tmax_",1:12,".bil",sep=""))
>x<-biovars(prec=prec,tmin=tmin,tmax=tmax)
> x
class : RasterBrick
dimensions : 3600, 8640, 12 (nrow, ncol, nlayers)
resolution : 0.04166667, 0.04166667 (x, y)
extent : -180, 180, -60, 90 (xmin, xmax, ymin, ymax)
projection : NA
values : C:/DOCUME~1/Marco/LOCALS~1/TMP/R_raster_tmp/raster_tmp_8984740455.grd
min values : 42 -65458 -1017 0 71 0 -65439 22 23 56 ...
max values : 65456 213 1 34159 65534 65513 65534 65507 65503 65518 ...
However, I thought there should be 19 bioclim variables. As you already mentioned, there are more arguments in biovars, besides those that are, but I donβt know what it is. could you help me?
Another problem is that I got an error while writing these variables:
>writeRaster(x,paste(getwd(),"/wc_2_5m_HADCM3_B2a_2080_1.grd",sep=""))
Error in dim(res) <- c(ncols, raster@data@nlayers * nrows) :
dims [product 933120] do not match the length of object [889920]
and when I tried to record them in the frequency band, I got the following error:
>for (i in 10:12) {
>writeRaster(x[[i]],paste(getwd(),"/wc_2_5m_HADCM3_B2a_2080_",i,".grd",sep=""),overwrite=TRUE)
}
Error in result[, i] <- readBin(raster@file@con, what = dtype, n = ncols, :
replacement has length zero
Three input variables are the same size, for example:
> prec
class : RasterStack
dimensions : 3600, 8640, 12 (nrow, ncol, nlayers)
resolution : 0.04166667, 0.04166667 (x, y)
extent : -180, 180, -60, 90 (xmin, xmax, ymin, ymax)
projection : NA
min values : 0 0 0 0 0 0 0 0 0 0 ...
max values : 65535 65535 65535 65535 65535 65535 65535 65535 65535 65535 ...
Can anyone explain why? Thanks in advance ~