Hello,

I need to take the first column of data in a raster object and append it (i.e. 
cbind) to the final column, creating a new object with an additional column in 
the process. Speed is critical for my particular application.

Here is a generic example, with my hack that I am hoping you can speed up a bit:

#Example raster
r <- raster(ncols=5, nrows=10)
r[] <- runif(ncell(r)) * 1:ncell(r)

#New raster will have one more column than original
new=r
ncol(new)=ncol(new)+1

#Set values to 'new'; final column will be identical to first
new=setValues(new,cbind(as.matrix(r),r[,1]))

Thanks!
Kevin
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to