Detailed description |
Hi Robert,
writeRaster of a RasterStack (nodatavalue = -Inf) returns a RasterBrick with nodatavalue = NA.
This can cause problems down the road (readCells.R:l86) if you query pixel values from a single layer with "[[" which turns NAchanged to TRUE but leaves nodatavalue at NA
### raster version 2.4-19 and 2.4-18 ##
r <- stack(raster(val=1, ncol=1, nrow=1))
## NA data value is -Inf
r@layers[[1]]@file
rf <- writeRaster(r, rasterTmpFile(), datatype="INT1S")
## nodatavalue is NA, NAchanged is FALSE
rf@file
## Get first layer: -> NAchanged is TRUE, but nodatavalue is NA
rf[[1]]@file
## Getting values
rf[1]
#> layer
#> [1,] 1
rf[[1]][1]
#> Error in if (x@file@nodatavalue < 0) { :
#> missing value where TRUE/FALSE needed
Cheers
Benjamin
|
|