[R-sig-Geo] Antw: Writing Raster values to .txt file

2012-10-03 Thread Matteo Mattiuzzi
Hi, the only way I can see is to use ?xyFromCell r - raster() r[] - 1:ncell(r) r - brick(r,r*2) vals - getValues(r) coords - xyFromCell(r,1:ncell(r)) res - cbind(coords,vals) write.table(res,file1.txt) Matteo Tiffany Smith 03.10.12 22.34 Uhr Hello, I'm trying to write out the

Re: [R-sig-Geo] Antw: Writing Raster values to .txt file

2012-10-03 Thread Robert J. Hijmans
Tiffany, You can also use r - raster() r[] - 1:ncell(r) r - brick(r,r*2) p - rasterToPoints(r) write.table(p, file2.txt) This will add the x and y, but omit NA cells. It also allows to you to use an expression to subset the values you want (e.g. only values 0) Robert On Wed, Oct 3, 2012 at