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:
"Traceback (most recent call last):
File "D:/NASA/Data/SPoRT LIS/Extract-subdata.py", line 24, in <module>
for raster in rasterList:
TypeError: 'NoneType' object is not iterable"
What is my code's problem? Your help is really appreciated.
<SPAN class="comment token"># Import arcpy module</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="comment token"># Load required toolboxes</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>ImportToolbox<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Model Functions"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Script arguments</SPAN>
LIS_HIST_201601010000_d01_grb <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> LIS_HIST_201601010000_d01_grb <SPAN class="operator token">==</SPAN> '<SPAN class="comment token">#' or not LIS_HIST_201601010000_d01_grb:</SPAN>
LIS_HIST_201601010000_d01_grb <SPAN class="operator token">=</SPAN> <SPAN class="string token">"D:\\NASA\\Data\\SPoRT LIS\\201601\\LIS_HIST_201601050000.d01.grb"</SPAN> <SPAN class="comment token"># provide a default value if unspecified</SPAN>
v_Name__tif <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> v_Name__tif <SPAN class="operator token">==</SPAN> '<SPAN class="comment token">#' or not v_Name__tif:</SPAN>
v_Name__tif <SPAN class="operator token">=</SPAN> <SPAN class="string token">"D:\\NASA\\Data\\SPoRT LIS\\Output\\%Name%.tif"</SPAN> <SPAN class="comment token"># provide a default value if unspecified</SPAN>
<SPAN class="comment token"># Local variables:</SPAN>
v201601 <SPAN class="operator token">=</SPAN> <SPAN class="string token">"D:\\NASA\\Data\\SPoRT LIS\\201601"</SPAN>
Subdataset_ID <SPAN class="operator token">=</SPAN> <SPAN class="string token">"3"</SPAN>
Name <SPAN class="operator token">=</SPAN> <SPAN class="string token">"LIS_HIST_201601050000.d01.grb"</SPAN>
<SPAN class="comment token"># Process: Iterate Rasters</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>IterateRasters_mb<SPAN class="punctuation token">(</SPAN>v201601<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NOT_RECURSIVE"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Process: Extract Subdataset</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>ExtractSubDataset_management<SPAN class="punctuation token">(</SPAN>LIS_HIST_201601010000_d01_grb<SPAN class="punctuation token">,</SPAN> v_Name__tif<SPAN class="punctuation token">,</SPAN> Subdataset_ID<SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>