this might work, your file link doesn't provide access to me so I created a guess example
library(terra) x <- rast(matrix(sample(0:255, 12), 3)) file.tif <- tempfile(fileext = ".tif") #writeRaster(x, file.tif, gdal = "NBITS=8", datatype = "INT1U") #rast(file.tif) terra has its own controls over the options, some interact/overlap with the gdal ones I haven't explored that HTH, Mike On Mon, Jan 31, 2022 at 5:52 AM Rik Ferreira <rikferreiraal...@gmail.com> wrote: > > Hello! > > How a raster image can be exported as a 8 bit GeoTIFF image? > > I'm downloading a 8 bit image from this link: > http://geoinfo.cnps.embrapa.br/documents/2918/download, cropping it with a > vector mask, treating it, and exporting it with terra package (writeRaster > function). > > However, the original image is a GeoTIFF with 8 bit depth but the output > image (terra package, writeRaster function) is a 32 bit image. > > I can control it with `gdal = "NBITS=8"` argument to writeRaster but i get > such warning: > > Warning message: > > In x@ptr$writeRaster(opt) : > > GDAL Message 6: > > /mnt/HDD/STORAGE/r-projects/raster-bit-depth/output/recorte.tif: Only > > NBITS=16 is supported for data type Float32 > > > > How can I export this raster as a 8 bit GeoTIFF image with terra package? > > -- > Rik Ferreira Alves > Graduando em Geografia - Unimontes > https://rikferreira.netlify.app/ > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo -- Michael Sumner Software and Database Engineer Australian Antarctic Division Hobart, Australia e-mail: mdsum...@gmail.com [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo