covert bulk NetCDF files to rasters

09-30-2019 10:01 PM
New Contributor

Dear community, 

Could you please to instruct me to write an ArcPy or Python code to convert multiple NetCDF files to rasters? 

I failed to use Iterator/ModelBuilder. 

I found a code to convert 1 NetCDF to a raster using MakeNetCDFRasterLayer function. However, I don't know how to write a loop to read through all NetCDF files.

I attached here 3 NetCDF files as an example for my dataset. 

All comments are appreciated.

Thank you so much.

# Import system modules

import arcpy

# Set local variables

inNetCDFFile = "C:/data/netcdf/"

variable = "pptx"

XDimension = "lon"

YDimension = "lat"

outRasterLayer = "rainfall"

bandDimmension = ""

dimensionValues = ""

valueSelectionMethod = ""

cellRegistration = ""


# Execute MakeNetCDFRasterLayer

arcpy.MakeNetCDFRasterLayer_md(inNetCDFFile, variable, XDimension, YDimension,

                               outRasterLayer, bandDimmension, dimensionValues,

                               valueSelectionMethod, cellRegistration)

0 Kudos
0 Replies