I want to convert the datatype of a raster to integer. For example:
x <- raster(nrow=10,ncol=10)
its datatype is float
dataType(x)
[1] "FLT4S"
then I round the pixel values of x by
y <- round(x)
dataType(y)
[1] "FLT4S"
How can I change the dataType of y to int?
Best Answer
Just tell it:
read the help for
dataType
to make sure you are doing the right thing though. This doesn't change R's internal storage mode:If what you really meant to ask was "how do I change the underlying storage type of raster data" then possibly you can just change the storage mode of the appropriate values:
Or just coerce the values: