I'm trying to utilize the extractSubdataset_management tool on a large set of GRB files. Each GRB file has a different number of subdatasets.

Is there any way to execute this tool on all subdatasets contained in each GRB rather than specifying the number of bands?

code so far as follows:

import os
import arcpy

path = "C:/CHRIS/testfolder/testgrib"
gribs = os.listdir(path)
grib = gribs

print os.getcwd()

grb = arcpy.env.workspace = "C:/CHRIS/testfolder/testgrib"

for item in gribs:
    print item
    os.mkdir(os.path.join(path, item + '.subdata'))
    folder = path + "/" + item + ".subdata"
    for i in range(0,115):
            arcpy.ExtractSubDataset_management(item, folder + "/test" + numb + ".tif", numb)
        except Exception as e:
            print e

so inside the "testgrib" folder are 2 .grb files. One of the files has 112 subdatasets, while the second file has 114 subdatasets. If I specify my range from 0-112, I get an output of 0-112, but in doing so it will omit the remaining 2 subdatasets from the second .grb file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.