Sorry, I meant:

"I can try later today with Manifold System, which may be helpful as an
independent tool, maybe".

On Fri, Nov 5, 2010 at 11:14 AM, Michael Sumner <mdsumner@gmail.com> wrote:

> Ok, thanks. I can try later today with Manifold System, which may be. I'm
> not sure of other non-GDAL tools to double check TIFFs with. (ArcGIS 10 uses
> GDAL but I don't know to what extent).
>
> Is the output above what you expect, or what you get? That's what I get.
> Sorry to be dim, but I don't see where you've specified what's actually
> wrong (and I haven't explored enough to see if that's easy to determine from
> the code).
>
> That's a cunning use of formals() to change defaults for a function - a bit
> radical for my taste, but I like it.
>
> Cheers, Mike.
>
>   On Fri, Nov 5, 2010 at 11:00 AM, Oliver Soong <osoong+r@gmail.com<osoong%2Br@gmail.com>
> > wrote:
>
>> 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_1band@data$band1 <- as.integer(SP27GTIF@data$band1 > 85)
>> img_1bit_2band <- SP27GTIF
>> img_1bit_2band@data <- data.frame(
>>  band1 = img_1bit_1band@data$band1,
>>  band2 = as.integer(SP27GTIF@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(reread@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.
>>
>
>
>
>  --
> Michael Sumner
> Institute for Marine and Antarctic Studies, University of Tasmania
> Hobart, Australia
> e-mail: mdsumner@gmail.com
>



-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner@gmail.com

	[[alternative HTML version deleted]]

