AnsweredAssumed Answered

Error in multiple netCDF file processing followed by raster projection

Question asked by dljayasekera on Jul 26, 2017
Latest reply on Jul 26, 2017 by dljayasekera

Hi,

 

I have multiple netCDF files I need to make a "netCDF raster" layer and then "project raster" and save as a ".tif" file. I have the following script but this gives me an error message.

 

Please see the code and error message below:

 

Thanks in advance.

 

# Import system modules  
import arcpy, sys
from arcpy import env 
from arcpy.sa import * 
 
# Input data source 
arcpy.env.workspace = r"C:/Users/jayaskeradl/Desktop/weekly_avg_project" 
arcpy.env.overwriteOutput = True 
 
# Set output folder 
OutputFolder = r"C:/Users/jayaskeradl/Desktop/weekly_avg_project/output" 
 
# Loop through a list of files in the workspace 
NCfiles = arcpy.ListFiles("*.nc") 
 
for filename in NCfiles: 
     print("Processing: " + filename) 
     inNCfiles = arcpy.env.workspace + "//" + filename 
     fileroot = filename[0:(len(filename)-3)] 
     TempLayerFile = "SM_amount" 
     outRaster = OutputFolder + "//" + fileroot 
    # Process: Make NetCDF Raster Layer 
     arcpy.MakeNetCDFRasterLayer_md(filename, "var250", "lon", "lat", TempLayerFile, "", "", "BY_VALUE") 
     arcpy.ProjectRaster_management(filename, TempLayerFile,"GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]", "NEAREST", "0.125 0.125", "NAD_1983_To_WGS_1984_1", "", "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
    # Process: Copy Raster 
     arcpy.CopyRaster_management(TempLayerFile, outRaster + ".tif", "", "", "", "NONE", "NONE", "") 
 
 
print "***DONE!!!" 
print arcpy.GetMessages()


ExecuteError: Failed to execute. Parameters are not valid.
Undefined coordinate system for input dataset.
Failed to execute (ProjectRaster).

Outcomes