[R-sig-Geo] raster::predict: more than one single output

Agustin Lobo alobolistas at gmail.com
Sat Sep 24 11:48:58 CEST 2011

I'm using raster::predict using predict.lda():

> srndpc20000lda <- lda(srndpcclasses[,1:5],srndpcclasses[,37])
> PCAtoMedian_6yrsclass20000 <- predict(object=PCAtoMedian_6yrs,model=srndpc20000lda)
> PCAtoMedian_6yrsclass20000
class       : RasterLayer
dimensions  : 1289, 1289, 1661521  (nrow, ncol, ncell)
resolution  : 0.008928571, 0.008928571  (x, y)
extent      : 30.99554, 42.50446, 1.495536, 13.00446  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
values      : in memory
min value   : 1
max value   : 4

But I would also need the rest of the output provided by
predict.lda(), in particular a layer with the posterior
probabilities to mask out those pixels which do not have a high
probability for any of the classes.
>From the help page of MASS::predict.lda():

 a list with components

class   The MAP classification (a factor)
posterior   posterior probabilities for the classes
x   the scores of test cases on up to dimen discriminant variables

As far as I  understand, only "class" is returned by raster::predict.
Am I wrong and there is actually a way to get the posteriors?
Otherwise, could that be added in the future?



More information about the R-sig-Geo mailing list