Hello, I am new to python and netcdf files and am trying to batch convert a bunch of netcdf files to rasters. When I run it only the last file in the folder seems to be being converted and copied. Here is the script I am using:
import arcpy
import arcpy as ap
from arcpy import env
from arcpy.sa import*
arcpy.env.workspace = "C:/Users/sutor/Desktop/KC_Trial"
arcpy.env.overwriteOutput = True
OutputFolder = "C:/Users/Desktop/KC_Trial"
NCfiles = arcpy.ListFiles("*.nc")
for filename in NCfiles:
print ("Processing: " + filename)
inNCfiles = arcpy.env.workspace + "/" + filename
fileroot = filename[0:(len(filename)-3)]
TempLayerFile = "cdf_KC"
outRaster = OutputFolder + "/" + fileroot
arcpy.MakeNetCDFRasterLayer_md(inNCfiles, "", "x", "y", TempLayerFile, "", "", "BY_VALUE")
arcpy.CopyRaster_management(TempLayerFile, outRaster + ".tif", "", "", "", "NONE", "NONE", "")
any ideas how to loop through the entire folder?