<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Looking at the code, it appears that GDAL actually hard codes any TRE that takes anything that cannot be parsed as a string (e.g. nitfimage.c NITFReadICHIPB). So, for BANDSB with its EXISTENCE_MASK and SCALE_FACTOR would need to be hard coded as opposed to
being defined just within the nitf_spec.xml. Is this the correct interpretation?</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks!</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Adam<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Brad Hards <bradh@frogmouth.net><br>
<b>Sent:</b> Wednesday, November 6, 2019 2:54 AM<br>
<b>To:</b> Edson, Adam Robert <are131@psu.edu>; gdal-dev@lists.osgeo.org <gdal-dev@lists.osgeo.org><br>
<b>Cc:</b> Bradley, Eliza S <esb165@psu.edu><br>
<b>Subject:</b> RE: [gdal-dev] python GDAL issue</font>
<div> </div>
</div>
<style>
<!--
@font-face
{font-family:Wingdings}
@font-face
{font-family:"Cambria Math"}
@font-face
{font-family:Calibri}
@font-face
{font-family:Consolas}
p.x_MsoNormal, li.x_MsoNormal, div.x_MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
a:link, span.x_MsoHyperlink
{color:blue;
text-decoration:underline}
a:visited, span.x_MsoHyperlinkFollowed
{color:purple;
text-decoration:underline}
pre
{margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New"}
p.x_MsoListParagraph, li.x_MsoListParagraph, div.x_MsoListParagraph
{margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
p.x_msonormal0, li.x_msonormal0, div.x_msonormal0
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
p.x_xmsonormal, li.x_xmsonormal, div.x_xmsonormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
span.x_HTMLPreformattedChar
{font-family:Consolas}
p.x_xxmsonormal, li.x_xxmsonormal, div.x_xxmsonormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
p.x_xxxmsonormal, li.x_xxxmsonormal, div.x_xxxmsonormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif}
span.x_EmailStyle25
{font-family:"Calibri",sans-serif;
color:windowtext}
.x_MsoChpDefault
{font-size:10.0pt}
@page WordSection1
{margin:72.0pt 72.0pt 72.0pt 72.0pt}
div.x_WordSection1
{}
ol
{margin-bottom:0cm}
ul
{margin-bottom:0cm}
-->
</style>
<div lang="EN-AU" link="blue" vlink="purple">
<div class="x_WordSection1">
<p class="x_MsoNormal"><span style="">Hi Adam,</span></p>
<p class="x_MsoNormal"><span style=""> </span></p>
<p class="x_MsoNormal"><span style=""><a href="https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fcodice%2Fimaging-nitf%2Fpull%2F196&data=02%7C01%7Care131%40psu.edu%7C1f5f02d357214ab1cac808d7628e8df2%7C7cf48d453ddb4389a9c1c115526eb52e%7C0%7C0%7C637086236748108876&sdata=r%2BZS3nYRN2M%2B7VFqmSJt%2F3lHXduFeMMIBfNALX9S43A%3D&reserved=0" originalsrc="https://github.com/codice/imaging-nitf/pull/196" shash="QqwkZ7dTbF/42jJqntxhtC/b2cYajfokgha5tcsvdhJv6te8L5eUx6GSvaaC49F+KuApPJ5NPkxPUiOYr81fOPBCLteUSj33pFny8L2YcXIC+M3YlWQf2vdbhaHHwBK6pD5TGuqjsSsb+TUcNAyZ8mfLaRXl361Uhf7d3AFWOWQ=">https://github.com/codice/imaging-nitf/pull/196</a>
is the work I did for my java implementation.</span></p>
<p class="x_MsoNormal"><span style=""> </span></p>
<p class="x_MsoNormal"><span style="">The spec definition I came up should be directly applicable.</span></p>
<p class="x_MsoNormal"><span style=""> </span></p>
<p class="x_MsoNormal"><span style="">However for it to work in GDAL, we need at least:</span></p>
<ul type="disc" style="margin-top:0cm">
<li class="x_MsoListParagraph" style=""><span style="">Support for parsing / using the IEEE 754 encoding (which I called type=”IEEE754”)</span></li><li class="x_MsoListParagraph" style=""><span style="">Support for parsing / using the 32bit integer encoding (which I called type=”UINT”)</span></li><li class="x_MsoListParagraph" style=""><span style="">Support for the “&” condition operator (for bitmask tests)</span></li><li class="x_MsoListParagraph" style=""><span style="">Unit tests</span></li></ul>
<p class="x_MsoNormal"><span style=""> </span></p>
<p class="x_MsoNormal"><span style="">I think I can hack my unit test code to output some test files.</span></p>
<p class="x_MsoNormal"><span style=""> </span></p>
<p class="x_MsoNormal"><span style="">Brad</span></p>
<p class="x_MsoNormal"><span style=""> </span></p>
<p class="x_MsoNormal"><span style=""> </span></p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_MsoNormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Edson, Adam Robert <are131@psu.edu>
<br>
<b>Sent:</b> Wednesday, 6 November 2019 1:36 AM<br>
<b>To:</b> Brad Hards <bradh@frogmouth.net>; gdal-dev@lists.osgeo.org<br>
<b>Cc:</b> Bradley, Eliza S <esb165@psu.edu><br>
<b>Subject:</b> Re: [gdal-dev] python GDAL issue</span></p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Brad,</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Sorry it took so long to get back to you.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">I am interested in collaborating on this with you.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Any help would be appreciated!</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Thanks!</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black">Adam</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="x_divRplyFwdMsg">
<p class="x_MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> Brad Hards <<a href="mailto:bradh@frogmouth.net">bradh@frogmouth.net</a>><br>
<b>Sent:</b> Monday, October 14, 2019 6:16 PM<br>
<b>To:</b> Edson, Adam Robert <<a href="mailto:are131@psu.edu">are131@psu.edu</a>>;
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a> <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>><br>
<b>Subject:</b> RE: [gdal-dev] python GDAL issue</span> </p>
<div>
<p class="x_MsoNormal"> </p>
</div>
</div>
<p class="x_xmsonormal">I think the problem is that there isn’t any real way to handle the IEEE-754 (or raw int/uint bitmask) in GDAL at the moment.
</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Working through the part you’ve posted:</p>
<p class="x_xmsonormal">S is the unit quantity</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">The part that looks like:</p>
<p class="x_xmsonormal">B\\0\\0\\0</p>
<p class="x_xmsonormal">is therefore the SCALE FACTOR, which is really IEEE 754-2008 binary encoded, and the existing TRE XML definition and parsing code doesn’t handle that case AFAICT.</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">This part is the ROW_GSD and COL_GSD + units:</p>
<p class="x_xmsonormal">0030.00</p>
<p class="x_xmsonormal">M</p>
<p class="x_xmsonormal">0030.00</p>
<p class="x_xmsonormal">M</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">In that case, I think there is a missing value in the TRE (because there has to be four bytes, and there are only three shown in your sample, which I assume is the test data that NGA derived from LANDSAT 8).</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">I’ve also been looking at handling “weird” TREs better (on and off for a while). I have a Java implementation that shares the XML definition, and the plan is to add two new types to the field definition:</p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"><</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:attribute</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:#9CDCFE">name</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4">=</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#CE9178">"type"</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:#9CDCFE">use</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4">=</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#CE9178">"optional"</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"><</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:simpleType</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"><</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:restriction</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:#9CDCFE">base</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4">=</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#CE9178">"xs:string"</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"><</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:enumeration</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:#9CDCFE">value</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4">=</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#CE9178">"string"</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">/></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"><</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:enumeration</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:#9CDCFE">value</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4">=</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#CE9178">"integer"</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">/></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"><</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:enumeration</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:#9CDCFE">value</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4">=</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#CE9178">"real"</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">/></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"><</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:enumeration</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:#9CDCFE">value</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4">=</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#CE9178">"UINT"</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">/></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"><</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:enumeration</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:#9CDCFE">value</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4">=</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#CE9178">"IEEE754"</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">/></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"></</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:restriction</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"></</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:simpleType</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">></span></p>
<p class="x_xmsonormal" style="line-height:14.25pt; background:#1E1E1E"><span style="font-size:10.5pt; font-family:"Courier New"; color:#D4D4D4"> </span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray"></</span><span style="font-size:10.5pt; font-family:"Courier New"; color:#569CD6">xs:attribute</span><span style="font-size:10.5pt; font-family:"Courier New"; color:gray">></span></p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">(where UINT and IEEE754 values are new, and are binary encoded instead of string encoded).</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Happy to collaborate on this if you’re interested.</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal">Brad</p>
<p class="x_xmsonormal"> </p>
<p class="x_xmsonormal"> </p>
<div>
<div style="border:none; border-top:solid #E1E1E1 1.0pt; padding:3.0pt 0cm 0cm 0cm">
<p class="x_xmsonormal"><b><span lang="EN-US">From:</span></b><span lang="EN-US"> Edson, Adam Robert <<a href="mailto:are131@psu.edu">are131@psu.edu</a>>
<br>
<b>Sent:</b> Monday, 14 October 2019 10:02 PM<br>
<b>To:</b> Brad Hards <<a href="mailto:bradh@frogmouth.net">bradh@frogmouth.net</a>>;
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<b>Subject:</b> Re: [gdal-dev] python GDAL issue</span></p>
</div>
</div>
<p class="x_xmsonormal"> </p>
<div>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black">I am working on adding BANDSB and the other TREs listed in the SNIP document.</span></p>
</div>
<div>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black">I am not sure what you are asking for.</span></p>
</div>
<div>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black">However, here is the output from gdal.getMetadata('TRE') for the relevant portion of the BANDSB TRE</span></p>
</div>
<div>
<pre><span style="color:black">SPECTRAL RADIANCE SB\\0\\0\\0\\0\\0\\00030.00M0030.00M-------M-------M <br> <span style="background:yellow"> <a href="file://0/0DETECTOR">\\0\\0DETECTOR</a></span> \x7fU</span></pre>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black">This is the section from the radiometric_quantity field to wave_length_unit field.</span></p>
</div>
<div>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black">Thanks!</span></p>
</div>
<div>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black">Adam</span></p>
</div>
<div>
<p class="x_xmsonormal"><span style="font-size:12.0pt; color:black"> </span></p>
</div>
<div class="x_MsoNormal" align="center" style="text-align:center">
<hr size="1" width="98%" align="center">
</div>
<div id="x_x_divRplyFwdMsg">
<p class="x_xmsonormal"><b><span style="color:black">From:</span></b><span style="color:black"> Brad Hards <<a href="mailto:bradh@frogmouth.net">bradh@frogmouth.net</a>><br>
<b>Sent:</b> Saturday, October 12, 2019 1:51 AM<br>
<b>To:</b> Edson, Adam Robert <<a href="mailto:are131@psu.edu">are131@psu.edu</a>>;
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a> <<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>><br>
<b>Subject:</b> RE: [gdal-dev] python GDAL issue</span> </p>
<div>
<p class="x_xmsonormal"> </p>
</div>
</div>
<p class="x_xxmsonormal">GDAL’s NITF encoding doesn’t appear to have BANDSB yet: <a href="https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FOSGeo%2Fgdal%2Fblob%2Fmaster%2Fgdal%2Fdata%2Fnitf_spec.xml&data=02%7C01%7Care131%40psu.edu%7C1f5f02d357214ab1cac808d7628e8df2%7C7cf48d453ddb4389a9c1c115526eb52e%7C0%7C0%7C637086236748118873&sdata=xuRz7pAyFvAKu69gUu9Rn%2BYVZvA%2FC2NWkhuC%2FCfbkgI%3D&reserved=0" originalsrc="https://github.com/OSGeo/gdal/blob/master/gdal/data/nitf_spec.xml" shash="BwUptuGSIalbM9VJCUjmLIA80FcFnWoOEXcVD4TcuewInmLOKJaKVqvHYPKv2Whu8CvH+1NADcqJM/9T+UcqhKstwvKQ4C9xIfp7d73FW0QBJZ/ShZ65RPAX7ZOWcXfpo9FTuwHU5tRJLEFbrJwrr9M+z4PSngHIvGXYlJ8bBuk=">
https://github.com/OSGeo/gdal/blob/master/gdal/data/nitf_spec.xml</a></p>
<p class="x_xxmsonormal"> </p>
<p class="x_xxmsonormal">It would definitely help to see how that file encodes it. Can you open the NITF file, find the part that starts with BANDSB0nnnn (where 0nnnn is some length value), and copy out the following 0nnnn characters?</p>
<p class="x_xxmsonormal"> </p>
<p class="x_xxmsonormal">Brad</p>
<p class="x_xxxmsonormal"> </p>
</div>
</div>
</body>
</html>