<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=utf-8">
<meta name="Generator" content="Microsoft Word 15 (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;}
@font-face
{font-family:"Malgun Gothic";
panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
{font-family:"\@Malgun Gothic";
panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 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;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.gmail-gd15mcfceub
{mso-style-name:gmail-gd15mcfceub;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@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"><o:p> </o:p></p>
<p class="MsoNormal" style="text-indent:5.25pt">Please try<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:5.25pt"><o:p> </o:p></p>
<p class="MsoNormal" style="text-indent:5.25pt"><span style="font-size:12.0pt">$</span><span style="font-size:12.0pt">
</span><span style="font-size:12.0pt">gdalmdimtranslate -array "name=/swaths/mod35/Data Fields/Quality_Assurance,transpose=[2,1,0]"
</span><span class="gmail-gd15mcfceub"><span style="font-size:12.0pt;color:black;border:none windowtext 1.0pt;padding:0in;background:white">MOD35_L2.A2017161.1525.061.2017315035809.hdf test.tif</span></span><span style="font-size:12.0pt"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent:5.25pt"><o:p> </o:p></p>
<p class="MsoNormal" style="text-indent:5.25pt">as shown in [1], which I updated it today for MOD35_L2.
<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:5.25pt"><o:p> </o:p></p>
<p class="MsoNormal" style="text-indent:5.25pt">[1] <a href="https://github.com/hdfeos/zoo/tree/master/gdal">
https://github.com/hdfeos/zoo/tree/master/gdal</a><o:p></o:p></p>
<p class="MsoNormal" style="text-indent:5.25pt"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><b>From:</b> gdal-dev <gdal-dev-bounces@lists.osgeo.org> <b>
On Behalf Of </b>J. Antonio Guzmán Q.<br>
<b>Sent:</b> Friday, August 07, 2020 4:44 PM<br>
<b>To:</b> gdal-dev@lists.osgeo.org<br>
<b>Subject:</b> [gdal-dev] Extracting a band with gdalmdimtranslate<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:13.5pt;font-family:"Times New Roman",serif;color:black">Hi,</span><span style="font-size:18.0pt;font-family:"Times New Roman",serif;color:#0B5394"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:13.5pt;font-family:"Times New Roman",serif;color:black">I am trying to extract a band (byte 3) from the Quality_Assurance SDS of MODIS Cloud Mask swath product (MOD35-MYD35). Overall, I can not extract a band or array
using gdalwarp since the dimensions of the array seems to be [Along, Across, Bytes] [2040x1354x10] and not [Bytes, Along, Across]. Therefore, I am trying to use gdalmdimtranslate to first transpose the array (transpose=[2,0,1]) and then do the extraction as
GTiff. </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:13.5pt;font-family:"Times New Roman",serif;color:black">Despite this, I am not totally sure about code writing or logic for this; maybe some of you can help me.
</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:13.5pt;font-family:"Times New Roman",serif;color:black">My code is the foll<span style="background:white">owing for the enclosed file below</span></span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<pre style="margin-bottom:12.0pt;word-break:break-all;outline:currentcolor none medium;white-space:pre-wrap;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px" id="gmail-rstudio_console_output"><span class="gmail-gd15mcfceub"><span style="font-size:13.5pt;color:black;border:none windowtext 1.0pt;padding:0in;background:white">gdalmdimtranslate HDF4_EOS:EOS_SWATH:MOD35_L2.A2017161.1525.061.2017315035809.hdf:mod35:Quality_Assurance example.tif -scaleaxes 'QA_Dimension:mod35(3)'</span></span><o:p></o:p></pre>
<pre style="margin-bottom:12.0pt;word-break:break-all;outline:currentcolor none medium;white-space:pre-wrap;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px" id="gmail-rstudio_console_output"><span class="gmail-gd15mcfceub"><span style="font-size:13.5pt;font-family:"Times New Roman",serif;color:black;border:none windowtext 1.0pt;padding:0in;background:white">I am running this from the cmd as a test using gdal 3.1.1. I always get an </span></span><span class="gmail-gd15mcfceub"><span style="font-size:13.5pt;color:black;border:none windowtext 1.0pt;padding:0in;background:white">ERROR 5: </span></span><span style="font-size:13.5pt;color:black;border:none windowtext 1.0pt;padding:0in;background:white"><br><span class="gmail-gd15mcfceub">GDALDataset::GetRasterBand(-1) - Illegal band</span></span><o:p></o:p></pre>
<pre style="margin-bottom:12.0pt;word-break:break-all;outline:currentcolor none medium;white-space:pre-wrap;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px" id="gmail-rstudio_console_output"><span class="gmail-gd15mcfceub"><span style="font-size:13.5pt;font-family:"Times New Roman",serif;color:black;border:none windowtext 1.0pt;padding:0in;background:white">I also try to call the dimension in different ways out results. If you have a different approach to extract the Byte 3 of this SDS that is also welcome. </span></span><o:p></o:p></pre>
<pre style="word-break:break-all;outline:currentcolor none medium;white-space:pre-wrap;font-variant-ligatures:normal;font-variant-caps:normal;text-decoration-style:initial;text-decoration-color:initial;word-spacing:0px" id="gmail-rstudio_console_output"><span class="gmail-gd15mcfceub"><span style="font-size:13.5pt;font-family:"Times New Roman",serif;color:black;border:none windowtext 1.0pt;padding:0in;background:white">I also enclosed a .txt as a results of</span></span><span class="gmail-gd15mcfceub"><span style="font-size:13.5pt;color:black;border:none windowtext 1.0pt;padding:0in;background:white"> gdalinfo <o:p></o:p></span></span></pre>
<pre style="word-break:break-all"><span class="gmail-gd15mcfceub"><span style="font-size:13.5pt;color:black;border:none windowtext 1.0pt;padding:0in;background:white">MOD35_L2.A2017161.1525.061.2017315035809.hdf<o:p></o:p></span></span></pre>
<pre style="word-break:break-all"><o:p> </o:p></pre>
</div>
<div>
<p class="MsoNormal"><span style="font-size:18.0pt;font-family:"Times New Roman",serif;color:black;background:white">Best regards,</span><span style="font-size:18.0pt">
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:18.0pt;font-family:"Times New Roman",serif;color:black"><a href="https://drive.google.com/file/d/1fMZrfMLl18e_D6CjJbscwhLvoFFGORJp/view?usp=sharing">https://drive.google.com/file/d/1fMZrfMLl18e_D6CjJbscwhLvoFFGORJp/view?usp=sharing</a></span><span style="font-size:18.0pt;font-family:"Times New Roman",serif"><o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:18.0pt;font-family:"Times New Roman",serif;color:black"><a href="https://drive.google.com/file/d/1f7oda-N9YT_cyf7YRw80BNQZr2O0RUMe/view?usp=sharing">https://drive.google.com/file/d/1f7oda-N9YT_cyf7YRw80BNQZr2O0RUMe/view?usp=sharing</a></span><span style="font-size:18.0pt;font-family:"Times New Roman",serif"><o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">_______________________<br>
J. Antonio Guzmán Q., <i>M.Sc</i><br>
Ph.D Candidate and Vanier Scholar<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Earth and Atmospheric Sciences Department <o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>