<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7652.24">
<TITLE>How to specify the nodata index to be used when outputting a PC256 GTiff with GDAL/GTiff dirver</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">Hi,</FONT></SPAN>
</P>
<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">I have a LAYER based on a gtiff file reported as follows by gdalinfo :</FONT></SPAN>
</P>
<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> Band 1 Block=10800x1 Type=Byte, ColorInterp=Palette</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> NoData Value=255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> Color Table (RGB with 256 entries)</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 0: 255,0,255,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 1: 250,0,255,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 2: 240,0,255,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 3: 230,0,255,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> (snip)</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 253: 143,0,0,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 254: 140,0,0,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 255: 0,0,0,255</FONT></SPAN>
</P>
<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">I would like Mapserver to produce a gtiff output with the same palette as the above one, eg with </FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">255 as the nodata value. I just cannot see how to do that. Whatever I try,</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">it appears that the missing value is always assigned to palette index 0 in the</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial">output tiff file. For ex. here is what gdalinfo reports for the output file :</FONT></SPAN>
</P>
<P><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> Band 1 Block=1000x8 Type=Byte, ColorInterp=Palette</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> Color Table (RGB with 256 entries)</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 0: 0,0,0,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 1: 255,0,255,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 2: 250,0,255,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 3: 240,0,255,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> (snip)</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 252: 150,0,0,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 253: 147,0,0,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 254: 143,0,0,255</FONT></SPAN>
<BR><SPAN LANG="en-us"><FONT SIZE=2 FACE="Arial"> 255: 140,0,0,255</FONT></SPAN>
</P>
<P><SPAN LANG="fr-ca"><FONT SIZE=2 FACE="Arial">Note that there is no explicit "NoData Value= " indication. The input color palette has been "shifted down" by one position, with the former "255:0,0,0,255" entry now at top as "0: 0,0,0,255".</FONT></SPAN></P>
<P><SPAN LANG="fr-ca"><FONT SIZE=2 FACE="Arial">This annoying, because the byte values in the output tiff file do not match anymore those in the input file.</FONT></SPAN>
</P>
<P><SPAN LANG="fr-ca"><FONT SIZE=2 FACE="Arial">Is there away to avoid this problem (except requiring all my source tiff layers to be rewritten to use 0 as the nodata value instead of 255, which would be a big pain given their high number).</FONT></SPAN></P>
<P><SPAN LANG="fr-ca"><FONT SIZE=2 FACE="Arial">Regards,</FONT></SPAN>
</P>
<P><SPAN LANG="fr-ca"><FONT SIZE=2 FACE="Arial">Andre Gosselin</FONT></SPAN>
<BR><SPAN LANG="fr-ca"><FONT SIZE=2 FACE="Arial">Maurice Lamontagne Institute</FONT></SPAN>
</P>
</BODY>
</HTML>