[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)
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 at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list