DrColgate

arcpy.MakeNetCDFRasterLayer_md

Discussion created by DrColgate on Nov 9, 2011
I'm having trouble using the Dimension Values (Optional) argument in arcpy.MakeNetCDFRasterLayer_md.

Whatever I seem to do the output raster is always the first layer which is the default value. 

Below is my attempt to export all layers to raster in the time dimension.

def extractAllNetCDF():

    variable = "RRt_10m"
    x_dimension = "lon"
    y_dimension = "lat"
    band_dimension = ""
    dimension = "time"
    valueSelectionMethod = "BY_VALUE"

    outLoc = "E:/New Folder/"
    inNetCDF = "E:/netCDFFiles/RRt.nc"    

    nc_FP = arcpy.NetCDFFileProperties(inNetCDF)   
    nc_Dim = nc_FP.getDimensions()
    
    for dimension in nc_Dim:
        
        top = nc_FP.getDimensionSize(dimension)
        
        for i in range(0, top):

            if dimension == "time":                
                dimension_values = nc_FP.getDimensionValue(dimension, i)
                nowFile = str(dimension_values)

                arcpy.MakeNetCDFRasterLayer_md(inNetCDF, variable, x_dimension, y_dimension, nowFile, band_dimension, dimension_values, valueSelectionMethod)
                arcpy.CopyRaster_management(nowFile, outLoc + nowFile + ".img", "", "", "", "NONE", "NONE", "")

                print dimension_values, i
        
    


The print method at the end will show the dates as they should be and the index i is also moving alon so there is no reason to think that there are other problems with the code other than the Dimension Value being incorrect and reverting to the default.

Does anyone have any idea how to get the subsequent layers to export?  Is there any code online that has a specific example of this using the Dimension Value argument other than empty quotes?

Outcomes