AnsweredAssumed Answered

Extract subdataset from GRIB files based on their file names using Python.

Question asked by Ameneh on Jun 29, 2017
Latest reply on Jun 29, 2017 by rastrauch

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.

 

# Import arcpy module
import arcpy

# Load required toolboxes
arcpy.ImportToolbox("Model Functions")

# Script arguments
LIS_HIST_201601010000_d01_grb = arcpy.GetParameterAsText(0)
if LIS_HIST_201601010000_d01_grb == '#' or not LIS_HIST_201601010000_d01_grb:
LIS_HIST_201601010000_d01_grb = "D:\\NASA\\Data\\SPoRT LIS\\201601\\LIS_HIST_201601050000.d01.grb" # provide a default value if unspecified

v_Name__tif = arcpy.GetParameterAsText(1)
if v_Name__tif == '#' or not v_Name__tif:
v_Name__tif = "D:\\NASA\\Data\\SPoRT LIS\\Output\\%Name%.tif" # provide a default value if unspecified


# Local variables:
v201601 = "D:\\NASA\\Data\\SPoRT LIS\\201601"
Subdataset_ID = "3"
Name = "LIS_HIST_201601050000.d01.grb"

# Process: Iterate Rasters
arcpy.IterateRasters_mb(v201601, "", "", "NOT_RECURSIVE")

# Process: Extract Subdataset
arcpy.ExtractSubDataset_management(LIS_HIST_201601010000_d01_grb, v_Name__tif, Subdataset_ID)

Outcomes