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, Apr 30, 2013 at 3:24 AM, Matteo Mattiuzzi <
matteo.mattiuzzi@boku.ac.at> wrote:

> Dear Ted,
>
>
> Isn't it simply that?
> out <- raster(nrow=20000,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
> #Prelims
> nColVal<-190
> 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){
>   print(i)
>   out <-
>
> writeValues(out,((outCol*(bs$row[i]-1))+1):((bs$row[i]+bs$nrows[i]-1)*outCol),bs$row[i])
> }
> out <- writeStop(out)
>
> tail(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@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
>

	[[alternative HTML version deleted]]

