dataType(x)
dataType(x) <- value
RasterLayer
objectLOG1S
FALSE (0) TRUE (1)
INT1S
-127 127
INT1U
0 255
INT2S
-32,767 32,767
INT2U
0 65,534
INT4S
-2,147,483,647 2,147,483,647
INT4U
0 4,294,967,296
FLT4S
-3.4e+38 3.4e+38
FLT8S
-1.7e+308 1.7e+308
}
For all integer types, except the single byte types, the lowest (signed) or highest (unsigned) value is used to store NA.
Single byte files do not have NA values.
Logical values are stored as signed single byte integers, they do have an NA value (-127)
INT4U
is available but they are best avoided as R does not support 32-bit unsigned integers.r <- raster(system.file("external/test.grd", package="raster"))
dataType(r)
s <- writeRaster(r, 'new.grd', datatype='INT2U', overwrite=TRUE)
dataType(s)
Run the code above in your browser using DataLab