Skip to content
Prev 26769 / 29559 Next

Problems converting rasters from float to integer.

Sorry, I was wrong - the actual issue is that the writeRaster argument is
"datatype", it gets conflated with the function that is dataType().

f <- "test_int.tif"
writeRaster(r, f, datatype = "INT2U", overwrite = TRUE)
s <- raster(f)
dataType(s)

[1] "INT2U"

Not the first time this has caught me out. I found it by checking
mode(readGDAL(f)[[1]]) and realizing that the TIFF type was Float32, prior
to the next steps.

HTH

:)

Cheers, Mike
On Fri, 24 Aug 2018 at 18:26 nevil amos <nevil.amos at gmail.com> wrote:

            
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia