Can be used to write prepared inputs on disk.

assessDataTypeGDAL(ras)

Arguments

ras

The RasterLayer or RasterStack for which data type will be assessed.

Value

The appropriate data type for the range of values in ras for using GDAL. See dataType for details.

Examples

library(raster) ## Byte ras <- raster(ncol = 10, nrow = 10) ras[] <- 1:100 assessDataTypeGDAL(ras)
#> [1] "Byte"
ras[] <- c(NA, 2:100) assessDataTypeGDAL(ras)
#> [1] "Byte"
##Int16 ras <- raster(ncol = 10, nrow = 10) ras <- setValues(ras, -1:98) assessDataTypeGDAL(ras)
#> [1] "Int16"
ras[] <- c(NA, -1:97) assessDataTypeGDAL(ras)
#> [1] "Int16"
ras[] <- round(runif(100, min = -32767, max = 32767)) assessDataTypeGDAL(ras)
#> [1] "Int16"
## UInt16 ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = 64000, max = 65000)) assessDataTypeGDAL(ras)
#> [1] "UInt16"
## UInt32 ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = 0, max = 500000000)) assessDataTypeGDAL(ras)
#> [1] "UInt32"
ras[14] <- NA assessDataTypeGDAL(ras)
#> [1] "UInt32"
## Int32 ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -200000000, max = 200000000)) assessDataTypeGDAL(ras)
#> [1] "Int32"
ras[14] <- NA assessDataTypeGDAL(ras)
#> [1] "Int32"
## Float32 ras <- raster(ncol = 10, nrow = 10) ras[] <- runif(100, min = -10, max = 87) assessDataTypeGDAL(ras)
#> [1] "Float32"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -3.4e+26, max = 3.4e+28)) assessDataTypeGDAL(ras)
#> [1] "Float32"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = 3.4e+26, max = 3.4e+28)) assessDataTypeGDAL(ras)
#> [1] "Float32"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -3.4e+26, max = -1)) assessDataTypeGDAL(ras)
#> [1] "Float32"