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

Matteo Mattiuzzi matteo.mattiuzzi at boku.ac.at
Tue Apr 30 09:24:56 CEST 2013

Dear Ted,

Isn't it simply that?
out <- raster(nrow=20000,ncol=1900)#modisRasterAll
out[] <- 1:ncell(out)


>>> Ted Rosenbaum  04/29/13 11:28 PM >>>

I am trying to assign a unique ID number to each tile in a large raster

My code is below:

##Write tile indexed MODIS file
outFileName <- 'tmp.grd'

#Set up raster
out <- raster(nrow=20000,ncol=nColVal)#modisRasterAll

##Get number of colums and blocksize
outCol <- ncol(out)
bs <- blockSize(out)

##Write to file
out <- writeStart(out,outFileName,overwrite=TRUE)
for(i in 1:bs$n){
  out <-
out <- writeStop(out)


When I run this code with nColVal=190, I get the expected result from
tail(out): a sequence of numbers.  However, when I run this code with
nColVal=1900, I do not and instead get
"37999996 38000000 38000000 38000000" for out[20000,1897:1900].

I would like to get instead "37999997 37999998 37999999 38000000".

Thanks for any assistance,

Ted Rosenbaum
Department of Economics
Yale University

    [[alternative HTML version deleted]]

R-sig-Geo mailing list
R-sig-Geo at r-project.org

More information about the R-sig-Geo mailing list