Reading data using backends#
Introduction#
You can read different types of files in xr.open_dataset
by specifying the engine to be used:
import xarray as xr
xr.open_dataset("my_file.grib" , engine="cfgrib")
Navigating Xarray backends can be confusing, so we recommend checking out this flow chart to help you figure out which engine you need and how to use it.
You can see what backends are currently available in your working environment
with xarray.backends.list_engines()
.
Why use the Xarray backend API to write your own backend?#
Your users don’t need to learn a new interface; they can use
xr.open_dataset
with theengine
kwarg.With little extra effort you can have lazy loading with Dask. Simply implement a function for reading blocks and Xarray will manage lazy loading with Dask for you.
It’s easy to implement: using the backend API (introduced in v0.18.0), you don’t need to integrate any code in Xarray.
More Information#
See the documentation for more details on adding and registering a new backend.
Follow the tutorials on creating a new backend for binary files.
Links to internal backends#
Links to external backends (not comprehensive)#
cfgrib - GRIB
tiledb - TileDB
rioxarray - GeoTIFF, JPEG-2000, ESRI-hdr, etc (via GDAL)
xarray-sentinel - Sentinel-1 SAFE
…