Re: [R-sig-Geo] Writing to Large Raster File

2013-04-30 Thread Ted Rosenbaum
Hi All, Changing the data type to INT4U worked for my application (14400 rows and 19200 columns). Thank you all for your help! On Tue, Apr 30, 2013 at 1:30 PM, Robert J. Hijmans wrote: > This is indeed because of precision loss due to FLT4S. Numbers larger > than 16777216 cannot be recovered t

Re: [R-sig-Geo] Writing to Large Raster File

2013-04-30 Thread Robert J. Hijmans
This is indeed because of precision loss due to FLT4S. Numbers larger than 16777216 cannot be recovered to the exact integer from a 4 byte floating point file. To avoid this I will change the default that 'raster' uses to FLT8S. This will double file sizes if the default is used. Ted, you can achi

Re: [R-sig-Geo] Writing to Large Raster File

2013-04-30 Thread Matteo Mattiuzzi
Hi Tom In fact there is a difference: see ?dataType why I do not use 'INT4U'. Probably the reason is that writeStart (see ?writeRaster) uses FLT4S as default and adding values in blocks the function doesn't know that FLT4S is not enough where else with out[] <- 1:ncell(out) it knows! I think t

Re: [R-sig-Geo] Writing to Large Raster File

2013-04-30 Thread Tom Philippi
Ted & Matteo-- Is this perhaps a dataType problem? I don't recall the specifics of the significand of FLT4S but it's roughly 8 digits, so 3800 may exceed it. You might try changing the dataType to INT4U to see if the dataType is the problem. Tom 2 On Tue, Apr 30, 2013 at 7:22 AM, Matteo M

Re: [R-sig-Geo] Writing to Large Raster File

2013-04-30 Thread Matteo Mattiuzzi
Ted you are right! I have tried a few things and I can not explain the behaviour. @Robert may the example below helps a little further. I have also tried to write into a tif and an img file but it doesn't change. Also after reloading the file out <- raster("tmp.grd") the problem persists. Start

Re: [R-sig-Geo] Writing to Large Raster File

2013-04-30 Thread Ted Rosenbaum
Dear Matteo, Thanks for your response. You approach would work except that my computer can't handle it well since it loads everything into memory. That is why I used the more complicated approach outlined here ( http://cran.r-project.org/web/packages/raster/vignettes/functions.pdf). On Tue

Re: [R-sig-Geo] Writing to Large Raster File

2013-04-30 Thread Matteo Mattiuzzi
Dear Ted, Isn't it simply that? out <- raster(nrow=2,ncol=1900)#modisRasterAll out[] <- 1:ncell(out) tail(out) >>> Ted Rosenbaum 04/29/13 11:28 PM >>> Hi, I am trying to assign a unique ID number to each tile in a large raster file. My code is below: ##Write tile indexed MODIS file

[R-sig-Geo] Writing to Large Raster File

2013-04-29 Thread Ted Rosenbaum
Hi, I am trying to assign a unique ID number to each tile in a large raster file. My code is below: ##Write tile indexed MODIS file #Prelims nColVal<-190 outFileName <- 'tmp.grd' #Set up raster out <- raster(nrow=2,ncol=nColVal)#modisRasterAll ##Get number of colums and blocksize outCol <-