I am collecting some precipitation data (centimeters of precipitation per day) from the Gridmet dataset (http://www.climatologylab.org/gridmet.html). The data comes in a NetCDF format and there is a different band for each day of the year. So the entire raster has 365 bands or dimensions, and at each pixel there are 365 individual measurements for cm of precipitation. Note that Gridmet has a bunch of data on other climate indicators in separate files.

Gridmet data sample

How many bands or dimensions can a single NetCDF file contain?

I was trying to google this, but did not find anything.

Is there a limit on the number of bands (I call them bands because I am used to thinking in tif rasters), or is there a bound on the total amount of data in the file, and so I can have unlimited bands until the data max is reached?

The reason I was asking is that I want to consolidate a bunch of datasets into a single or handful of NetCDF files.

If I want precipitation for 20 years in a single NetCDF file, which would be 365*20 = 7300 bands or dimensions, would that work?

That way I can pull the full time-series for any point.

  • 3
    Be careful with your terminology. A daily time step for one year does not mean that there are 365 dimensions. It is still one dimension, time. Feb 24, 2020 at 22:22

1 Answer 1


NetCDF 4 datasets can have many dimensions of unlimted size.

Dimensions are used to define the shape of data in netCDF.

Dimensions for a netCDF dataset are defined when it is created, while the netCDF dataset is in define mode. Additional dimensions may be added later by reentering define mode. A netCDF dimension has a name and a length. In a netCDF classic or 64-bit offset file, at most one dimension can have the unlimited length, which means variables using this dimension can grow along this dimension. In a netCDF-4 file multiple unlimited dimensions are supported.

There is a suggested limit (1024) to the number of dimensions that can be defined in a single netCDF dataset. The limit is the value of the predefined macro NC_MAX_DIMS. The purpose of the limit is to make writing generic applications simpler. They need only provide an array of NC_MAX_DIMS dimensions to handle any netCDF dataset. The implementation of the netCDF library does not enforce this advisory maximum, so it is possible to use more dimensions, if necessary, but netCDF utilities that assume the advisory maximums may not be able to handle the resulting netCDF datasets.


Incidentally there are tools (notably Python's xarray) that allow you to work with multiple NetCDF files on disk as though they are a single file, so it may not be necessary to concatenate these files into one large file.

  • Oh this makes a lot of sense. Thanks for the info @alphabetasoup. This is very helpful. I did not now about the xarray tie in too, so that is really nice. I should be able to read NetCDF files through rasterio too right?
    – krishnab
    Feb 25, 2020 at 1:40
  • Yeah, it's possible. Although in my experience, using xarray for NetCDF data is a lot easier. Feb 25, 2020 at 3:22
  • Great. I will give that a shot. I have used xarray before, but the interface was a bit tricky. But I suppose once I get it working, it will be fine.
    – krishnab
    Feb 25, 2020 at 3:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.