Here's an example:
require(rgdal) formals(paste)$sep <- "" SP27GTIF <- readGDAL( system.file("pictures/SP27GTIF.TIF", package = "rgdal")[1], output.dim=c(100,100) ) img_1bit_1band <- SP27GTIF img_1bit_1b...@data$band1 <- as.integer(sp27g...@data$band1 > 85) img_1bit_2band <- SP27GTIF img_1bit_2b...@data <- data.frame( band1 = img_1bit_1b...@data$band1, band2 = as.integer(sp27g...@data$band1 > 170) ) for(img in c("img_1bit_1band", "img_1bit_2band")) { cat(paste("*** Correct Stats: ", img, "\n")) print(sapply(get(img)@data, table)) for(compress in c("NONE", "DEFLATE", "LZW", "CCITTRLE", "CCITTFAX3", "CCITTFAX4")) { file <- paste(img, "_", compress, ".tif") writeGDAL(get(img), file, type = "Byte", options = c("NBITS=1", paste("COMPRESS=", compress))) cat(paste("Compression: ", compress, " from ", file, "\n")) reread <- readGDAL(file, silent = TRUE) print(sapply(rer...@data, table)) } cat("\n") } The expected output is: *** Correct Stats: img_1bit_1band band1 0 3086 1 6914 Compression: NONE from img_1bit_1band_NONE.tif band1 0 3086 1 6914 Compression: DEFLATE from img_1bit_1band_DEFLATE.tif band1 0 3086 1 6914 Compression: LZW from img_1bit_1band_LZW.tif band1 0 3086 1 6914 Compression: CCITTRLE from img_1bit_1band_CCITTRLE.tif band1 0 3086 1 6914 Compression: CCITTFAX3 from img_1bit_1band_CCITTFAX3.tif band1 0 3086 1 6914 Compression: CCITTFAX4 from img_1bit_1band_CCITTFAX4.tif band1 0 3086 1 6914 *** Correct Stats: img_1bit_2band band1 band2 0 3086 8353 1 6914 1647 Compression: NONE from img_1bit_2band_NONE.tif band1 band2 0 3086 8353 1 6914 1647 Compression: DEFLATE from img_1bit_2band_DEFLATE.tif band1 band2 0 3086 8353 1 6914 1647 Compression: LZW from img_1bit_2band_LZW.tif band1 band2 0 3086 8353 1 6914 1647 Compression: CCITTRLE from img_1bit_2band_CCITTRLE.tif band1 band2 0 6131 8783 1 3869 1217 Compression: CCITTFAX3 from img_1bit_2band_CCITTFAX3.tif band1 band2 0 6131 8783 1 3869 1217 Compression: CCITTFAX4 from img_1bit_2band_CCITTFAX4.tif band1 band2 0 6131 8783 1 3869 1217 Everything looks fine except CCITT compression with 2 bands. I wasn't able to dig up Windows GDAL 1.7.1 binaries, and the 1.7.0 binaries from FW_Tools seem to give similar behavior, although it's a little hard to check because neither ArcGIS nor ENVI seems to like any of the multi-band files. _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo