[R-sig-Geo] as.data.frame.default error using Raster package predict

Ned Horning horning at amnh.org
Tue Oct 26 22:59:30 CEST 2010


Hi - I am trying to use the predict function from the raster package to 
predict using a random forest object using the following command:
 > predict (randfor, imageRaster, filename=outImage, progress='text', 
format='GTiff', datatype='FLT4S', type='response', overwrite=TRUE)

I get the following error:
Error in as.data.frame.default(newdata) :
   cannot coerce class structure("RasterStack", package = "raster") into 
a data.frame

I get the same error when trying this with a gbm object. The input image 
is an 8-band 32 bit floating point image. I am able to use the predict 
function with random forests when the image with the predictor variables 
and the data used to build the model are different. Here is the 
description of the RasterStack image I am using:
--
 > imageRaster
class       : RasterStack
filename    :
nlayers     : 8
nrow        : 121
ncol        : 133
ncell       : 16093
projection  : +proj=utm +zone=19 +ellps=clrk66 +datum=NAD27 +units=m 
+no_defs +nadgrids=@conus, at alaska, at ntv2_0.gsb, at ntv1_can.dat
min value   : NA NA NA NA NA NA NA NA
max value   : NA NA NA NA NA NA NA NA
xmin        : 272614.0766
xmax        : 285914.0766
ymin        : 4862555.9603
ymax        : 4874655.9603
xres        : 100
yres        : 100
--
Any idea what the problem might be?

Ned



More information about the R-sig-Geo mailing list