Thanks for your help

Here my sextante R script (I had remove original Cat line)

<i>##[RF_Classification]=group
##shapefile=vector
##attName=string class
##inImage=raster
##numsamps=number 1000
##outImage=output raster
library("maptools")
library("sp")
library("randomForest")
library("raster")
nd =0
vec =shapefile
satImage =inImage
for (b in 1:nlayers(satImage)) { NAvalue(satImage@layers[[b]]) <- nd }
allAtt <- slot(vec, "data")
tabAtt <-table(allAtt[[attName]])
uniqueAtt <-as.numeric(names(tabAtt))
for (x in 1:length(uniqueAtt)) {
  class_data<- vec[vec[[attName]]==uniqueAtt[x],]
  areas <- sapply(slot(class_data, "polygons"), slot, "area")
  nsamps <- ceiling(numsamps*(areas/sum(areas)))
  for (i in 1:dim(class_data)[1]) {
    xy_class <- spsample(class_data[i,], type="random", n=nsamps[i])
    if (i == 1) cpts <- xy_class
    else cpts <- rbind(cpts, xy_class)
  }
classpts <- cpts
  if (x == 1) {
    xy_allClasses<- classpts
  } else {
    xy_allClasses<- rbind(xy_allClasses, classpts)
  }

temp <- overlay(vec, xy_allClasses)
response <- temp[[attName]]
trainvals <- cbind(response, extract(satImage, xy_allClasses))
randfor <- randomForest(as.factor(response) ~., data=trainvals, importance=TRUE, na.action=na.omit)
varImpPlot(randfor)
predict(satImage, randfor, filename=outImage, progress='text', format='GTiff', datatype='INT1U', type='response', overwrite=TRUE)</i>

Thanks again !


        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1560.n6.nabble.com/Run-R-RandomForest-classification-Script-using-Sextante-tp5034709p5034740.html">Re: Run R RandomForest classification Script using Sextante</a><br/>
Sent from the <a href="http://osgeo-org.1560.n6.nabble.com/Quantum-GIS-User-f4125267.html">Quantum GIS - User mailing list archive</a> at Nabble.com.<br/>