Can be used to write prepared inputs on disk.

assessDataType(ras)

# S3 method for Raster
assessDataType(ras)

# S3 method for RasterStack
assessDataType(ras)

# S3 method for default
assessDataType(ras)

Arguments

ras

The RasterLayer for which data type will be assessed. Only single layers supported.

Value

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

Examples

## LOG1S library(raster)
#> Loading required package: sp
ras <- raster(ncol = 10, nrow = 10) ras[] <- rep(c(0,1),50) assessDataType(ras)
#> [1] "LOG1S"
ras[] <- rep(c(TRUE,FALSE),50) assessDataType(ras)
#> [1] "LOG1S"
ras[] <- c(NA, NA, rep(c(0,1),49)) assessDataType(ras)
#> [1] "LOG1S"
ras <- raster(ncol = 10, nrow = 10) ras[] <- c(0, NaN, rep(c(0,1),49)) assessDataType(ras)
#> [1] "LOG1S"
## INT1S ras[] <- -1:98 assessDataType(ras)
#> [1] "INT1S"
ras[] <- c(NA, -1:97) assessDataType(ras)
#> [1] "INT1S"
## INT1U ras <- raster(ncol = 10, nrow = 10) ras[] <- 1:100 assessDataType(ras)
#> [1] "INT1U"
ras[] <- c(NA, 2:100) assessDataType(ras)
#> [1] "INT1U"
## INT2U ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = 64000, max = 65000)) assessDataType(ras)
#> [1] "INT2U"
## INT2S ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -32767, max = 32767)) assessDataType(ras)
#> [1] "INT2S"
ras[54] <- NA assessDataType(ras)
#> [1] "INT2S"
## INT4U ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = 0, max = 500000000)) assessDataType(ras)
#> [1] "INT4U"
ras[14] <- NA assessDataType(ras)
#> [1] "INT4U"
## INT4S ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -200000000, max = 200000000)) assessDataType(ras)
#> [1] "INT4S"
ras[14] <- NA assessDataType(ras)
#> [1] "INT4S"
## FLT4S ras <- raster(ncol = 10, nrow = 10) ras[] <- runif(100, min = -10, max = 87) assessDataType(ras)
#> [1] "FLT4S"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -3.4e+26, max = 3.4e+28)) assessDataType(ras)
#> [1] "FLT4S"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = 3.4e+26, max = 3.4e+28)) assessDataType(ras)
#> [1] "FLT4S"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -3.4e+26, max = -1)) assessDataType(ras)
#> [1] "FLT4S"
## FLT8S ras <- raster(ncol = 10, nrow = 10) ras[] <- c(-Inf, 1, rep(c(0,1),49)) assessDataType(ras)
#> [1] "FLT8S"
ras <- raster(ncol = 10, nrow = 10) ras[] <- c(Inf, 1, rep(c(0,1),49)) assessDataType(ras)
#> [1] "FLT8S"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -1.7e+30, max = 1.7e+308)) assessDataType(ras)
#> [1] "FLT8S"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = 1.7e+30, max = 1.7e+308)) assessDataType(ras)
#> [1] "FLT8S"
ras <- raster(ncol = 10, nrow = 10) ras[] <- round(runif(100, min = -1.7e+308, max = -1)) assessDataType(ras)
#> [1] "FLT8S"
# stack ras <- raster(ncol = 10, nrow = 10) ras[] <- rep(c(0,1),50) ras1 <- raster(ncol = 10, nrow = 10) ras1[] <- round(runif(100, min = -1.7e+308, max = -1)) sta <- stack(ras, ras1) assessDataType(sta)
#> [1] "LOG1S" "FLT8S"