Gridded & climate data

NetCDF, GRIB and Zarr grids with a time axis: opening, subsetting, averaging and regridding them with xarray.

A gridded dataset as a labelled cube of time, latitude and longitude, with one time slice selected. a labelled array, selected by coordinate rather than by positionlonlattimeds.sel(time="2026-04-11")by coordinate valueds.isel(time=102)by position — a different questionMixing the two up is silent: both return an array of exactly the shape you expected

Climate and reanalysis data arrives as a labelled array: a few variables over latitude, longitude and time, in NetCDF, GRIB or Zarr. xarray gives it names, so you subset by coordinate value rather than by position, and reductions carry their dimension names with them.

The traps are quiet ones. Selecting by position when you meant by label returns an array of exactly the right shape. A variable packed into sixteen bits with a scale factor reads correctly through one library and not through another, and a derived field written with its parent’s encoding silently overflows. A mean over latitude and longitude without cos-latitude weighting over-counts the poles, and the answer still looks reasonable.

Below: the concepts cover the formats, the packing and what a regrid actually computes; the how-to guides open, subset, average and regrid; and the fixes are the values that come back wrong and the maps that come out shifted.

Learning paths run through this topic too — see the end of this page.

🧭 Start with the concepts

The ideas the how-to guides below assume you already have.

Show every concept in this topic

⚙️ Then do the task

Step-by-step walkthroughs with code you can copy and adapt.

Show every how-to guide in this topic

🔧 When it breaks

The errors this topic produces, with the cause explained rather than just the command.

Show every fix in this topic

Related topics

Subjects that keep coming up alongside this one, most overlap first.

Keep browsing

Gridded & climate data sits in Imagery & point clouds. Every topic on the site is listed on the topics index.