<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hi,<o:p></o:p></p><p class=MsoNormal> Hopefully this is a quick one, I think the answer’s so obvious I’m missing it. I’m trying to use GDAL to create a TIFF copy of a NITF file. I’ve downloaded and compiled 1.8.1 (under Windows) and used gdal_translate from the command line to create the copy. I can view the new file from IrfanView and everything looks good.<o:p></o:p></p><p class=MsoNormal> When I try to do this programmatically from Java, however, things break down. I’m using the Java bindings from 1.7 in case that’s an issue; I’ve tried a number of things, but haven’t recompiled the bindings yet. My code is:<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Dataset ds=gdal.<i>Open</i>(datasetFilename, gdalconstConstants.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>GA_ReadOnly</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New"'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>if</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'> (ds == </span><b><span style='font-size:10.0pt;font-family:"Courier New";color:#7F0055'>null</span></b><span style='font-size:10.0pt;font-family:"Courier New";color:black'>) {</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> System.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>out</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.println(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"GDALOpen failed - "</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'> + gdal.<i>GetLastErrorNo</i>());</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> System.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>out</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.println(gdal.<i>GetLastErrorMsg</i>());</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> gdal.<i>GDALDestroyDriverManager</i>();</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> System.<i>exit</i>(1);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> }</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> </span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> System.</span><i><span style='font-size:10.0pt;font-family:"Courier New";color:#0000C0'>out</span></i><span style='font-size:10.0pt;font-family:"Courier New";color:black'>.println(</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"Image has "</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>+ds.getRasterCount()+</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>" bands"</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> Driver driv=gdal.<i>GetDriverByName</i>(saveFormat);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span style='font-size:10.0pt;font-family:"Courier New";color:black'> driv.CreateCopy(outFilename+</span><span style='font-size:10.0pt;font-family:"Courier New";color:#2A00FF'>"."</span><span style='font-size:10.0pt;font-family:"Courier New";color:black'>+saveFormat,ds);</span><span style='font-size:10.0pt;font-family:"Courier New"'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New";color:black'> <o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;color:black'> </span><span style='color:black'>Which looks about as basic as it gets. The file is created, but it’s slightly shorter than gdal_translate’s version of the copy and contains one color as opposed to the original count of 256 colors. The histogram of the new image is completely flat. Both images are single-band, though the gdal_translate copy has 8BPP and the new one has 24BPP. The dimensions remain unchanged and it’s a valid TIFF file, just with bad pixel data.<o:p></o:p></span></p><p class=MsoNormal><span style='color:black'> This occurs with most of the NITFs in my set. The NITFs are viewable using FWTools and look good; the TIFFs created by gdal_translate match them. It’s just my Java code that’s producing blank images.<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> Am I missing something obvious?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> Thanks,<o:p></o:p></p><p class=MsoNormal> Mike<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>