<?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: Extract subdataset from GRIB files based on their file names using Python. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extract-subdataset-from-grib-files-based-on-their/m-p/428355#M33669</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hint: check out &lt;A href="https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?sr=search&amp;amp;searchId=c55b56e4-85ea-493a-8abb-8c8afa6f5460&amp;amp;searchIndex=5"&gt;https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?sr=search&amp;amp;searchId=c55b56e4-85ea-493a-8abb-8c8afa6f5460&amp;amp;searchIndex=5&lt;/A&gt;‌&amp;nbsp;&amp;nbsp;&amp;nbsp; to help with syntax and spacing, and so other can respond with line numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not familiar with&amp;nbsp; grb format, but add a few print statements in your code to make sure your variables are being set correctly.&amp;nbsp; If I assuming&lt;/P&gt;&lt;PRE class="" style="color: #000000; background-color: #ffffff; font-size: 9.0pt;"&gt;&lt;CODE&gt;v_Name__tif &lt;SPAN class=""&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class=""&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;wasn't set, and instead set it manually,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;v_Name__tif = "D:\\NASA\\Data\\SPoRT LIS\\Output\\%Name%.tif"&lt;BR /&gt;print(v_Name__tif)&lt;BR /&gt;D:\NASA\Data\SPoRT LIS\Output\%Name%.tif&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have a path with&amp;nbsp;&amp;nbsp; %Name%&amp;nbsp;&amp;nbsp; in it.&amp;nbsp; I'm assuming that is not what you want, and maybe you are trying to substitute another variable in there?&amp;nbsp;&amp;nbsp; You should also try to avoid spaces and other special characters in path names&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/curtvprice/blog/2016/05/07/how-to-name-things-in-arcgis?sr=search&amp;amp;searchId=963f23c7-3e9e-487f-bcda-10562c68c0d2&amp;amp;searchIndex=3"&gt;https://community.esri.com/people/curtvprice/blog/2016/05/07/how-to-name-things-in-arcgis?sr=search&amp;amp;searchId=963f23c7-3e9e-487f-bcda-10562c68c0d2&amp;amp;searchIndex=3&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Jun 2017 22:24:38 GMT</pubDate>
    <dc:creator>RebeccaStrauch__GISP</dc:creator>
    <dc:date>2017-06-29T22:24:38Z</dc:date>
    <item>
      <title>Extract subdataset from GRIB files based on their file names using Python.</title>
      <link>https://community.esri.com/t5/python-questions/extract-subdataset-from-grib-files-based-on-their/m-p/428354#M33668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px;"&gt;I have daily GRIB data which I want to extract their subdataset and convert the result to .tif files. I wrote a code in python but I received this erroe: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;&lt;STRONG&gt;"Traceback (most recent call last):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;&lt;STRONG&gt; File "D:/NASA/Data/SPoRT LIS/Extract-subdata.py", line 24, in &amp;lt;module&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;&lt;STRONG&gt; for raster in rasterList:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;&lt;STRONG&gt;TypeError: 'NoneType' object is not iterable"&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-size: 12px;"&gt;What is my code's problem? Your help is really appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Import arcpy module&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

&lt;SPAN class="comment token"&gt;# Load required toolboxes&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ImportToolbox&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Model Functions"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Script arguments&lt;/SPAN&gt;
LIS_HIST_201601010000_d01_grb &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; LIS_HIST_201601010000_d01_grb &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; '&lt;SPAN class="comment token"&gt;#' or not LIS_HIST_201601010000_d01_grb:&lt;/SPAN&gt;
 LIS_HIST_201601010000_d01_grb &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"D:\\NASA\\Data\\SPoRT LIS\\201601\\LIS_HIST_201601050000.d01.grb"&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# provide a default value if unspecified&lt;/SPAN&gt;

v_Name__tif &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; v_Name__tif &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; '&lt;SPAN class="comment token"&gt;#' or not v_Name__tif:&lt;/SPAN&gt;
 v_Name__tif &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"D:\\NASA\\Data\\SPoRT LIS\\Output\\%Name%.tif"&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# provide a default value if unspecified&lt;/SPAN&gt;


&lt;SPAN class="comment token"&gt;# Local variables:&lt;/SPAN&gt;
v201601 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"D:\\NASA\\Data\\SPoRT LIS\\201601"&lt;/SPAN&gt;
Subdataset_ID &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"3"&lt;/SPAN&gt;
Name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"LIS_HIST_201601050000.d01.grb"&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Process: Iterate Rasters&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;IterateRasters_mb&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;v201601&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;""&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"NOT_RECURSIVE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;# Process: Extract Subdataset&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ExtractSubDataset_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;LIS_HIST_201601010000_d01_grb&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; v_Name__tif&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Subdataset_ID&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:16:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-subdataset-from-grib-files-based-on-their/m-p/428354#M33668</guid>
      <dc:creator>AmenehTavakol</dc:creator>
      <dc:date>2021-12-11T19:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Extract subdataset from GRIB files based on their file names using Python.</title>
      <link>https://community.esri.com/t5/python-questions/extract-subdataset-from-grib-files-based-on-their/m-p/428355#M33669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hint: check out &lt;A href="https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?sr=search&amp;amp;searchId=c55b56e4-85ea-493a-8abb-8c8afa6f5460&amp;amp;searchIndex=5"&gt;https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?sr=search&amp;amp;searchId=c55b56e4-85ea-493a-8abb-8c8afa6f5460&amp;amp;searchIndex=5&lt;/A&gt;‌&amp;nbsp;&amp;nbsp;&amp;nbsp; to help with syntax and spacing, and so other can respond with line numbers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not familiar with&amp;nbsp; grb format, but add a few print statements in your code to make sure your variables are being set correctly.&amp;nbsp; If I assuming&lt;/P&gt;&lt;PRE class="" style="color: #000000; background-color: #ffffff; font-size: 9.0pt;"&gt;&lt;CODE&gt;v_Name__tif &lt;SPAN class=""&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class=""&gt;.&lt;/SPAN&gt;GetParameterAsText&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;1&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;wasn't set, and instead set it manually,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;v_Name__tif = "D:\\NASA\\Data\\SPoRT LIS\\Output\\%Name%.tif"&lt;BR /&gt;print(v_Name__tif)&lt;BR /&gt;D:\NASA\Data\SPoRT LIS\Output\%Name%.tif&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have a path with&amp;nbsp;&amp;nbsp; %Name%&amp;nbsp;&amp;nbsp; in it.&amp;nbsp; I'm assuming that is not what you want, and maybe you are trying to substitute another variable in there?&amp;nbsp;&amp;nbsp; You should also try to avoid spaces and other special characters in path names&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/people/curtvprice/blog/2016/05/07/how-to-name-things-in-arcgis?sr=search&amp;amp;searchId=963f23c7-3e9e-487f-bcda-10562c68c0d2&amp;amp;searchIndex=3"&gt;https://community.esri.com/people/curtvprice/blog/2016/05/07/how-to-name-things-in-arcgis?sr=search&amp;amp;searchId=963f23c7-3e9e-487f-bcda-10562c68c0d2&amp;amp;searchIndex=3&lt;/A&gt;‌&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jun 2017 22:24:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extract-subdataset-from-grib-files-based-on-their/m-p/428355#M33669</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2017-06-29T22:24:38Z</dc:date>
    </item>
  </channel>
</rss>

