

  

Thanks a lot for cracking this Barry.... But, I am still not able to completely understand this as I am  not so experienced in R! I got an image display with 4 plots in it. If I  am not wrong, are these the plots of rainfall Values (or the gridded  dataset) for the 1st four days? can you explain this function's overall  purpose, so that I could know if I got it right!

I have some other doubts as well which i have mentioned below!

readTime <-
function(f,tm,x=69,y=65,size=4,type="double",NAvalue=-999){
c = file(f,open="rb")
seek(c,x*y*(tm-1)*size)                        #what is its purpose?
m=matrix(readBin(c,type,x*y,size),x,y)      
close(c)
m[abs(m-NAvalue)<.Machine$double.eps] = NA             # a  datavalue in matrix is checked for its lowest possible value and  assigned "NA" if its so?
m
}

par(mfrow=c(2,2))
for(p in 1:4){
image(readTime("rf0.5_1975.grd",p))
}

thank you again for your time and consideration!  Thanks,
Maha!

Quoting Barry Rowlingson <b.rowlingson@lancaster.ac.uk>:

> Anybody still reading this?
>
> I'm sometimes so stuck with sp-objects and rgdal that I forget that
> the easiest way to read raw binary data is with readBin. Wrap it into
> a function, make it a matrix, now I can easily read time slices:
>
> readTime <-
>   function(f,tm,x=69,y=65,size=4,type="double",NAvalue=-999){
>     c = file(f,open="rb")
>     seek(c,x*y*(tm-1)*size)
>     m=matrix(readBin(c,type,x*y,size),x,y)
>     close(c)
>     m[abs(m-NAvalue)<.Machine$double.eps] = NA
>     m
>   }
>
>  par(mfrow=c(2,2))
>  for(p in 1:4){
>  image(readTime("rf0.5_1975.grd",p))
>  }
>
>  I didn't realise it was India because my gdal virtual raster was sideways.
>
> Barry
>
	[[alternative HTML version deleted]]

