Skip to content
Prev 26768 / 29559 Next

Problems converting rasters from float to integer.

Roger,

there was a reproducible example in my post:  it seems to have got a bit
scrambled in your reply.

from the help in raster I thought that if I included  datatype="INT2S" in
the writeRaster() command the values would be formatted in the output file
( and the subsequent reading using raster() of that file) as integer  is
this not the case?

Here it is the reproducible example

v<-c(rep(1.00000,25),rep(0.00000,50),rep(NA,25))
m<-matrix(v,10,10)
r<-raster(m)
dataType(r)
writeRaster(r,"test_int.tif",dataType="INT2U",overwrite=T)
s<-raster("test_int.tif")
dataType(s)
On Fri, 24 Aug 2018 at 18:05, Roger Bivand <Roger.Bivand at nhh.no> wrote: