Monday, 2 December 2019

random forest - How to utilise single 'randomForest' model for several rasters in R?



I am using randomForest package in R to derive species distribution models. When I predict the model to the RasterStack containing the predictors in which the values were extracted to build my model, everything goes fine. The problem is that I would like to predict this model I generated in the present scenario to the same set of predictors in the past and future. However, R gives me an error message.


Past and present predictors RasterStack are the same extension, resolution, etc. This is not the problem.


Reading the help of the 'predict' function {raster package} in R, I found the following: "The names in the Raster object should exactly match those expected by the model. This will be the case if the same Raster object was used (via extract) to obtain the values to fit the model".


So, according to this, I can't predict my model to another RasterStack that was not used to obtain the values for the model. So, I would like to know another way that I could predict values from a present scenario to past or future scenarios.


Thanks a lot, Mariana




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...