How To: Export each time slice from a NetCDF layer as a single raster (*.tif)


The instructions provided describe how to export each time slice from a NetCDF layer as a single raster (*.tif).


A NetCDF layer must be created in the ArcMap table of contents before NetCDF raster bands can be exported. The needed toolbox and sample data can be downloaded here: NetCDF_time_slice_to_Raster.zip

  1. Start ArcMap and create a NetCDF raster layer from the NetCDF file.
  1. Navigate to ArcToolbox > Multidimension Tools > Make NetCDF Raster Layer.
  2. Select a file for Input netCDF File and set all the other parameters.

  3. Click OK. The tool creates a NetCDF raster layer and adds it to the table of contents.

  1. Right-click the NetCDF layer and navigate to Layer Properties > NetCDF. Select a Band Dimension if one has not already been selected.

  1. In ArcMap Catalog, browse to the downloaded data (NetCDF_time_slice_to_Raster.zip) which contains a toolbox inside a geodatabase.

  2. Open the NetCDF_time_slice_export script tool.
  3. Select the Input_NetCDF_layer and an Output Folder. Click OK to run the tool.

The tool exports all the time slices (bands) from the NetCDF raster layer as TIFs. Pasted below is the Python code used for this script tool. This code can be modified to meet various needs.  
# Import modules
import arcpy, os

Input_NetCDF_layer = arcpy.GetParameterAsText(0)
Output_Folder = arcpy.GetParameterAsText(1)

Input_Name = Input_NetCDF_layer
Output_Raster = Output_Folder + os.sep + "NetCDF_Raster.tif"

#Copy the NetCDF layer as a TIF file. 
arcpy.CopyRaster_management(Input_Name, Output_Raster)
arcpy.AddMessage(Output_Raster + " " + "created from NetCDF layer")

#Reading number of band information from saved TIF
bandcount = arcpy.GetRasterProperties_management (Output_Raster, "BANDCOUNT") 
resultValue = bandcount.getOutput(0)

count = 1
arcpy.AddMessage("Exporting individual bands from" + Output_Raster)

#Loop through the bands and copy bands as a seperate TIF file.
while count <= int(resultValue):
    Input_Raster_Name = Output_Raster + os.sep+ "Band_" + str(count)
    Output_Band = Output_Folder + os.sep + "Band_" + str(count) +".tif"
    arcpy.CopyRaster_management(Input_Raster_Name, Output_Band)
    arcpy.AddMessage("Band_" + str(count) +".tif" + " " "exported" + " " + "successfully")
    count +=1

# The following will delete the TIF file that was created by CopyRaster tool.  
arcpy.AddMessage("Tool Executed Successfully")