Dear all,
I have multiples raster files, i am trying to convert it in NetCDF file using Arcpy script . below script i am using for conversion. While i ran the below script , i am getting the error,
Below i have attached my raster file also, which i trying to convert in NetCDF format.
Error Code
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000840: The value is not a Raster Layer.
ERROR 000840: The value is not a Raster Catalog.
Failed to execute (RasterToNetCDF).
Below script i am using for conversion of raster to NetCDF.
import arcpy
from arcpy import env
# Set environment settings
env.workspace = "D:\2012A"
# Set local variables
inRaster = "D:\2012A"
outNetCDFFile = "D:\2012A/nppnetcdf.nc"
variable = "NPP"
units = "gCSqm"
XDimension = "x"
YDimension = "y"
bandDimension = ""
# Process: RasterToNetCDF
arcpy.RasterToNetCDF_md(inRaster, outNetCDFFile, variable, units,
XDimension, YDimension, bandDimension)
Solved! Go to Solution.
Dan Patterson Xander Bakker, Sorry for the late reply. I was out of station.
Thank you very much. Script is perfect working.
Xander Bakker As you mentioned the UNIT seems to be invalid, Actually I tried to assign the unit my own "gram carbon per square meter (gcsqm) " Howover it's not taking as a valid UNIT so I changed it to "Gram" now it's working perfectly.
xander_bakker i have one more request, can we convert those NetCDF as a time dimension single NetCDF ?
Once again thanks to all for your valuable contribution to solve the issue.
Hi shouvik jha , I'm glad you could solve the unit problem.
Not sure if ArcGIS can do this be default, but maybe the netCDF4 module could help:
I think it is in the conda distribution for ArcGIS PRO... but I would have to check
Dear Xander Bakker
Sorry to open this thread again.
Let say all the input file has date information in filename ie. r001_NPP_YYYY.MM.tif
From your script, is it possible to make the time dimension enabled based on date in the filename when saving into netCDF?
Hi Benny Istanto ,
To be honest, I don't see any option in the "arcpy.RasterToNetCDF_md" tool to allow this. Perhaps using the "band_dimension" parameter in combination with the "fields_to_dimensions" parameter you could do something, but I am not sure.