HOW TO

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

Last Published: July 21, 2022

Summary

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

Procedure

  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.
Image of the Make NetCDF Raster Layer window
  1. Click OK. The tool creates a NetCDF raster layer and adds it to the table of contents.
Image showing the Table of Contents window
  1. Right-click the NetCDF layer, and navigate to Layer Properties > NetCDF. Select a Band Dimension if one has not already been selected.
Image showing Band Dimension selected
  1. In ArcMap Catalog, browse to the downloaded data (NetCDF_time_slice_to_Raster.zip) which contains a toolbox inside a geodatabase.
Image showing folder with downloaded data
  1. Open the NetCDF_time_slice_export script tool.
  2. Select the Input_NetCDF_layer and an Output Folder. Click OK to run the tool.
Image showing the tool

The tool exports all the time slices (bands) from the NetCDF raster layer as TIFs. The following shows the Python code used for this script tool. This code can be modified to meet various needs.

# Import modules
import arcpy, os

#Inputs
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.Delete_management(Output_Raster,"#")
    
arcpy.AddMessage("Tool Executed Successfully")

Article ID:000011318

Software:
  • ArcMap 10 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic