HDF5 and NetCDF Explained: Groups, Dimensions and Attributes
How HDF5 and NetCDF organise scientific data, what attributes like units and fill values do, and how to slice a 3-D array and export it to CSV.

HDF5 and NetCDF Explained: Groups, Dimensions and Attributes
Climate models, satellite missions, ocean buoys, particle physics experiments and microscopes all produce data that does not fit neatly into a spreadsheet. HDF5 and NetCDF are the two most common containers for such data. Both store large arrays together with the information needed to interpret them, and both reward a few minutes spent learning how they are organised.
How HDF5 is organised
An HDF5 file works like a small file system. Groups act as folders and can be nested. Datasets are typed arrays of any number of dimensions, such as a 3-D grid of temperatures or a long table of particle hits. Attributes are small named values attached to a group or dataset, which is where units, descriptions and processing history usually live. Large datasets are often split into chunks and compressed, so a reader can fetch one slice without loading the whole file.
How NetCDF relates to it
NetCDF, developed by Unidata, describes data in terms of named dimensions and variables. A temperature variable might be declared over the dimensions time, lat and lon, and separate coordinate variables give the actual time values, latitudes and longitudes. There are two physical forms:
- NetCDF classic has its own simple binary layout, in three variants: CDF-1, CDF-2 with 64-bit offsets, and CDF-5.
- NetCDF-4 is stored as HDF5, with extra conventions for dimensions.
Many files also follow the CF conventions, which define attributes such as units, long_name, _FillValue, scale_factor and add_offset.
Worked example
The HDF5 and NetCDF file viewer includes a sample called temperature-sample.nc, a NetCDF classic CDF-1 file titled Sample gridded temperature. Its dimensions are time = 6, lat = 4 and lon = 3, and it has four variables:
| Variable | Shape | Units |
|---|---|---|
| time | 6 | days since 2024-06-01 |
| lat | 4 | degrees_north (20, 30, 40, 50) |
| lon | 3 | degrees_east (80, 90, 100) |
| temp | 6 × 4 × 3 | degC, air temperature at 2 m |
The summary counts 1 group, 4 datasets and 85 values, which is 6 + 4 + 3 + 72.
In Browse arrays, choose temp. Because it has three dimensions, the first one, time, becomes an index box, and the window shows a 4 × 3 slice with lat as rows and lon as columns. With the time index at 0, the rows read:
- lat 20: 30, 30.5, 31
- lat 30: 25.5, 26, 26.5
- lat 40: 21, 21.5, 22
- lat 50: 16.5, 17, 17.5
The pattern is easy to read: it gets colder towards the north and slightly warmer towards the east. Set the time index to 3 and every value rises, with the warmest cell at 32.99 for lat 20 and lon 100. The chart plots one line per longitude column across the four latitude rows.
Press Whole dataset CSV and the 72 values of temp are written as a long table with the columns time, lat, lon and value, one row per cell. Note that these columns hold index positions, 0 to 5, 0 to 3 and 0 to 2, not the coordinate values; join them with the time, lat and lon variables if you need degrees and dates.
Reading the attributes
The Attributes tab puts every attribute in one table, with global attributes on the root row. In real files this is where you find units, the data source, the processing history and the fill value. Read it before you plot anything: a value of -9999 or 9.97e36 is almost always a fill value, not a measurement.
Common mistakes
Ignoring packing attributes. Some files store temperatures as short integers with a scale_factor and add_offset. The viewer shows values as stored and does not apply these, so multiply by the scale factor and add the offset yourself.
Confusing indexes with coordinates. Index 2 on the lat dimension is the third latitude, here 40 degrees north, not 2 degrees.
Opening HDF4 by mistake. Many older satellite products with the .hdf extension are HDF4, a different format. The viewer recognises them and suggests converting with h4toh5.
Exporting a full global grid to CSV. A daily global grid can hold hundreds of millions of values. Whole-dataset CSV stops at 5 million, so export slices or use a script for larger work.
Privacy and connection
NetCDF classic files are decoded by the page itself. HDF5 and NetCDF-4 files are read with h5wasm, the HDF5 library compiled to WebAssembly, which is fetched from a CDN the first time; your file is read locally and not uploaded. The viewer helps you understand a file's contents. It is not scientific advice, so check units and conventions against the data provider's documentation.



