I am doing species distribution modeling (ecological niche modeling) where I project a model to either current or future climate rasters (Bioclim variables).
When I predict to the current rasters (object=bio_stack), everything works, using this code:
#predict species current distribution using bio_stack
current_dist<-predict(object=bio_stack, model=mod_gam,filename="whitebark_current_dist_17April2014",
na.rm=TRUE, type="response", format="GTiff", overwrite=TRUE,
progress="text")
However, when I predict to the future rasters (object=future_bio_stack
), this code does not produce the results:
#predict species future distribution using future_bio_stack
future_dist<-predict(object = future_bio_stack, model=mod_gam,filename="whitebark_future_dist_17April2014",
fun=predict, na.rm=TRUE, type="response", format="GTiff", overwrite=TRUE,
progress="text")
Instead, I get this warning message:
In addition: Warning message:
In predict.gam(model, blockvals, ...) :
not all required variables have been supplied in newdata!
The future biostack layers to which I am projecting look ok in an image, with normal min and max values (I can not post the image without a reputation score).
However, the min and max values of the future_bio_stack look strange in the summary, especially compared to the bio_stack. Here is a summary of each of the stacks, with the min and max values provided:
> future_bio_stack
class : RasterStack
dimensions : 4800, 5880, 28224000, 5 (nrow, ncol, ncell, nlayers)
resolution : 0.008333333, 0.008333333 (x, y)
extent : -152, -103, 30, 70 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +no_defs
names : WC05future_clipped, WC06future_clipped, WC08future_clipped, WC13future_clipped, WC15future_clipped
min values : -32768, -32768, -32768, -32768, -32768
max values : 32767, 32767, 32767, 32767, 32767
> bio_stack
class : RasterStack
dimensions : 4800, 5880, 28224000, 5 (nrow, ncol, ncell, nlayers)
resolution : 0.008333333, 0.008333333 (x, y)
extent : -152, -103, 30, 70 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
names : WC05_clipped, WC06_clipped, WC08_clipped, WC13_clipped, WC15_clipped
min values : -56, -429, -145, 7, 5
max values : 457, 100, 332, 767, 129
Any ideas why bio_stack
is working with the predict
function but future_bio_stack
is not?