<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HDF to tiff : Extract in folders based on HDF file names in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356488#M28035</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Zia, since you put all the info in a different thread and are getting responses, you may want to delete this one so it doesn't remain an unanswered thread.&amp;nbsp; You won't be able to delete it from within your geonet inbox, but should be able to if you open it up Ina new tab (click on the title if going thru the inbox).&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Nov 2015 14:29:45 GMT</pubDate>
    <dc:creator>RebeccaStrauch__GISP</dc:creator>
    <dc:date>2015-11-18T14:29:45Z</dc:date>
    <item>
      <title>HDF to tiff : Extract in folders based on HDF file names</title>
      <link>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356483#M28030</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am processing&amp;nbsp; 190s HDF files&amp;nbsp; from a Folder (&lt;STRONG&gt;J:\RapidEyr_Atcor\HDF)&lt;/STRONG&gt;.&amp;nbsp; Here is the example of file name:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;AtmosCorrected_&lt;SPAN style="background: yellow;"&gt;4549227_2014-12-23_RE1_3A_278182&lt;/SPAN&gt;.hdf&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;AtmosCorrected_&lt;SPAN style="background: yellow;"&gt;4549227_2015-02-15_RE1_3A_278163&lt;/SPAN&gt;.hdf&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;AtmosCorrected_&lt;SPAN style="background: yellow;"&gt;4549227_2015-01-13_RE1_3A_278182&lt;/SPAN&gt;.hdf&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;AtmosCorrected_&lt;SPAN style="background: yellow;"&gt;4549227_2015-03-23_RE1_3A_278102&lt;/SPAN&gt;.hdf&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Each HDF&amp;nbsp; file contains 13 bands. But I want to extract the first&amp;nbsp; 5 bands from each of&amp;nbsp; HDF file and&amp;nbsp;&amp;nbsp; save as TIFF files in a folder created with [16:46] characters of&amp;nbsp; corresponding HDF file. &lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P&gt;Folder and files arrangement as like as below&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG style=": ; background: yellow; font-size: 10.0pt;"&gt;J:\RapidEyr_Atcor\TIF&lt;SPAN style="background: yellow;"&gt; \4549227_2015-02-15_RE1_3A_278163&lt;BR /&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; background: yellow;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4549227_2015-02-15_RE1_3A_278163&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;_b1. tif&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; background: yellow;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4549227_2015-02-15_RE1_3A_278163_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;b2.tif&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; background: yellow;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4549227_2015-02-15_RE1_3A_278163&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;_b3.tif&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; background: yellow;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4549227_2015-02-15_RE1_3A_278163_&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;b4.tif&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;, &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;STRONG&gt;&lt;SPAN style="font-size: 10.0pt; background: yellow;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4549227_2015-02-15_RE1_3A_278163&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;_b5.tif&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt; &lt;SPAN style="font-size: 10.0pt;"&gt;J:\RapidEyr_Atcor\TIF&lt;SPAN style="background: yellow;"&gt; \4549227_2015-01-13_RE1_3A_278182&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="background: yellow; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: yellow; font-size: 10.0pt;"&gt;4549227_2015-01-13_RE1_3A_278182_b1.tif&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="background: yellow; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4549227_2015-01-13_RE1_3A_278182_b2.tif&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="background: yellow; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: yellow; font-size: 10.0pt;"&gt;4549227_2015-01-13_RE1_3A_278182_b3.tif&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background: yellow; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4549227_2015-01-13_RE1_3A_278182_b4.tif&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="background: yellow; font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="background: yellow; font-size: 10.0pt;"&gt;4549227_2015-01-13_RE1_3A_278182_b4.tif&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think, first I have to create a output folder and name it with [16:46] characters of&amp;nbsp; one&amp;nbsp; HDF file, then apply arcpy.ExtractSubDataset for selecting the first five bands (0:4) from the corresponding HDF file.&amp;nbsp; And I have to run this process in a loop for all HDF files.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone help me to modify following codes to process all HDF files with batch mode.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Zia&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14477776617543862" data-renderedposition="749.7000122070312_8_913_255" jivemacro_uid="_14477776617543862"&gt;&lt;OL class="dp-py" start="1"&gt;&lt;LI&gt;&lt;SPAN class="keyword"&gt;import arcpy&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class="keyword"&gt;try:&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt; arcpy.env.workspace = r&lt;SPAN class="string"&gt;"J:\RapidEyr_Atcor\HDF"&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt; rasterListA = arcpy.ListRasters()&amp;nbsp; &lt;/LI&gt;&lt;LI&gt;&lt;SPAN class="keyword"&gt;for raster &lt;SPAN class="keyword"&gt;in&lt;/SPAN&gt; rasterListA:&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;tifOutA=&lt;SPAN class="string"&gt;"&lt;STRONG&gt;J:\\RapidEyr_Atcor\\TIFF&lt;/STRONG&gt;"+raster[&lt;SPAN class="number"&gt;16&lt;/SPAN&gt;:46]&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt; arcpy.ExtractSubDataset_management(raster,tifOutA+&lt;SPAN class="string"&gt;"_B1"+&lt;SPAN class="string"&gt;".tif"&lt;/SPAN&gt;, &lt;SPAN class="string"&gt;"0"&lt;/SPAN&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt; arcpy.ExtractSubDataset_management(raster,tifOutA+&lt;SPAN class="string"&gt;"_B2"+&lt;SPAN class="string"&gt;".tif"&lt;/SPAN&gt;, &lt;SPAN class="string"&gt;"1"&lt;/SPAN&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt; arcpy.ExtractSubDataset_management(raster,tifOutA+&lt;SPAN class="string"&gt;"_B3"+&lt;SPAN class="string"&gt;".tif"&lt;/SPAN&gt;, &lt;SPAN class="string"&gt;"2"&lt;/SPAN&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt; arcpy.ExtractSubDataset_management(raster,tifOutA+&lt;SPAN class="string"&gt;"_B4"+&lt;SPAN class="string"&gt;".tif"&lt;/SPAN&gt;, &lt;SPAN class="string"&gt;"3"&lt;/SPAN&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt; arcpy.ExtractSubDataset_management(raster,tifOutA+&lt;SPAN class="string"&gt;"_B5"+&lt;SPAN class="string"&gt;".tif"&lt;/SPAN&gt;, &lt;SPAN class="string"&gt;"4"&lt;/SPAN&gt;)&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class="keyword"&gt;except:&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class="keyword"&gt;print &lt;SPAN class="string"&gt;"Extract Subdataset example failed."&lt;/SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class="keyword"&gt;print arcpy.GetMessages()&amp;nbsp; &lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2015 16:54:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356483#M28030</guid>
      <dc:creator>ZiaAhmed</dc:creator>
      <dc:date>2015-11-17T16:54:42Z</dc:date>
    </item>
    <item>
      <title>Re: HDF to tiff : Extract in folders based on HDF file names</title>
      <link>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356484#M28031</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;could you format your code using one of the methods here &lt;A _jive_internal="true" data-containerid="1167" data-containertype="37" data-objectid="55181" data-objecttype="38" href="https://community.esri.com/blogs/dan_patterson/2015/10/16/script-formatting" target="_blank"&gt;&lt;SPAN style="color: #0066cc; text-decoration: underline;"&gt;Code Formatting... the basics++&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;your indentation is either incorrect or it didn't get carried over during the copy-paste&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; blah blah
&amp;nbsp;&amp;nbsp;&amp;nbsp; for bl in blah:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; blah blah
except
&amp;nbsp;&amp;nbsp;&amp;nbsp; blah blah&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:40:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356484#M28031</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T16:40:46Z</dc:date>
    </item>
    <item>
      <title>Re: HDF to tiff : Extract in folders based on HDF file names</title>
      <link>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356485#M28032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank. I do not understand want you want to say, i asking help for how to use file names create folders in a loop. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 01:37:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356485#M28032</guid>
      <dc:creator>ZiaAhmed</dc:creator>
      <dc:date>2015-11-18T01:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: HDF to tiff : Extract in folders based on HDF file names</title>
      <link>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356486#M28033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;True...but your code won't work since it isn't formatted properly because of indentation issues, which, if run should have generated error messages, and if they did, they would be useful to see.&amp;nbsp; Once, that is fixed, then it is a matter of dissecting the code. tifoutA&amp;nbsp; that should be indented as well, and I presume it is printing out a name but you are using a slice of the input name.&amp;nbsp; Through a print statement in after you have the name to make sure the name is correct.&amp;nbsp; So if you can provide documentation via print statements and error messages that would be great.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 02:02:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356486#M28033</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-11-18T02:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: HDF to tiff : Extract in folders based on HDF file names</title>
      <link>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356487#M28034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan,&lt;/P&gt;&lt;P&gt;I am able to extract bands&amp;nbsp; from HDF, but I have to run three python scripts: (1) First one create folders based on the name of HDF files and import HDF files in respective folders (2) Then 2nd Script extract&amp;nbsp; first 5 bands in folder and (3) 3rd one create a multi-tif file. This there anyway combine three scripts to make one? &lt;/P&gt;&lt;P&gt;I am going post all codes in another threads, Thanks again&lt;/P&gt;&lt;P&gt;Zia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 05:19:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356487#M28034</guid>
      <dc:creator>ZiaAhmed</dc:creator>
      <dc:date>2015-11-18T05:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: HDF to tiff : Extract in folders based on HDF file names</title>
      <link>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356488#M28035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Zia, since you put all the info in a different thread and are getting responses, you may want to delete this one so it doesn't remain an unanswered thread.&amp;nbsp; You won't be able to delete it from within your geonet inbox, but should be able to if you open it up Ina new tab (click on the title if going thru the inbox).&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Nov 2015 14:29:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/hdf-to-tiff-extract-in-folders-based-on-hdf-file/m-p/356488#M28035</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2015-11-18T14:29:45Z</dc:date>
    </item>
  </channel>
</rss>

