Ned, I think the order of the first two arguments is wrong and should be:
predict (imageRaster, randfor, filename=outImage, progress='text', format='GTiff', datatype='FLT4S', type='response', overwrite=TRUE) Robert On Tue, Oct 26, 2010 at 1:59 PM, Ned Horning <horn...@amnh.org> wrote: > 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 +nadgri...@conus,@alaska,@ntv2_0.gsb,@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 > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@stat.math.ethz.ch > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo