I'm learning randomForest classification method in R and I performed land-use classification with randomForest and raster packages. But when I try uesd a regression model produced with randomForest to predict in "raster" with the same operation, there is only a NA value RasterLayer left.enter image description here

what is wrong, the way I deal with datas or it can't do this in "raster" package

  • You are not giving us a reproducible example and it is very unclear exactly what you are asking. Have you fit a regression instance of RF? If so, on what data? It is a bad idea to fit a regression to catagorical (e.g., landcover) data. Are the rasters you are defining in the predict function actually in the model? If you provided your code and not just a screen shot of the error message the community may be able to provide some relevant advice. – Jeffrey Evans Oct 20 '14 at 21:12
  • thank all your helpful advises. I have result it, there is something wrong with my independent variable, there is one variable is factor, when I change it to – Logan Nov 7 '14 at 5:23
  • @logan I notice that you have two accounts. Please visit this page for instructions on how to merge them. – PolyGeo Nov 7 '14 at 6:09

Impossible to know from your description. But you can try things like the below to see what is going on:

# get values of a few cells
cells <- 100000:100010
x <- data.frame(w1[cells])

predict(s2.rf, x, type='response')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.