AnsweredAssumed Answered

Export time dimension NetCDF to raster format using ArcPy

Question asked by india123 on Jun 11, 2018
Latest reply on Jun 14, 2018 by xander_bakker

I have single NetCDF file which is time dimension NetCDF file, the netCDF file contains the monthly weather data for 20 years. I want to convert the NetCDF to raster tiff format and output of the raster as same the month and year name. below is code but it's producing the error in line number 29. Time format of the data is YY-MM-DD 2013-01-01 12:00, 2013-02-01 12:00, so on. How to loop all the time dimension.  

updated download link for input files: - Google Drive 


I tried to extract the layer manually using ArcGIS tool, it's successfully extracted. I have copied the code from ArcGIS 


dimension_values="time '01-01-2013 12:00:00'",
# Import system modules
import arcpy
from arcpy import env
from import *

outLoc = r"E:\Weather/"
inNetCDF = r"E:\Weather\"
variable = "slhf"
x_dimension = "lon"
y_dimension = "lat"
band_dimension = ""
dimension = "time"
valueSelectionMethod = "BY_VALUE"

nc_FP = arcpy.NetCDFFileProperties(inNetCDF)
nc_Dim = nc_FP.getDimensions()

for dimension in nc_Dim:
        if dimension == "time":
            top = nc_FP.getDimensionSize(dimension)
            for i in range(0, top):

                dimension_values = nc_FP.getDimensionValue(dimension, i)
                nowFile = str(dimension_values)
                nowFile = nowFile.translate(None, '/')
                # I needed after 2013
                if int(nowFile.split()[0].split('-')[-1])==2013:

                    dv1 = ["time", dimension_values]
                    dimension_values = [dv1]

                    arcpy.MakeNetCDFRasterLayer_md(inNetCDF, variable, x_dimension, y_dimension, nowFile, band_dimension, dimension_values, valueSelectionMethod)
                    print "success"
                    outname = outLoc + nowFile

                    arcpy.CopyRaster_management(nowFile, outname,"", "", "", "NONE", "NONE", "")

                else: print "DATA OUT OF RANGE"

Error message

ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000237: One or more dimensions are invalid
ERROR 000237: One or more dimensions are invalid
Failed to execute (MakeNetCDFRasterLayer).