GDALBackendEntrypoint

GDALBackendEntrypoint()

xarray backend for reading geospatial files via GDAL.

Methods

Name Description
guess_can_open Whether xarray should pick this engine when none is named.
open_dataset Open a dataset using GDAL.

guess_can_open

GDALBackendEntrypoint.guess_can_open(filename_or_obj)

Whether xarray should pick this engine when none is named.

Deliberately narrow. Only strings in a form that no other engine understands are considered: GDAL virtual file systems (/vsicurl/...), vrt:// connection strings and driver-prefixed strings (ZARR:"...", NETCDF:"...":var). Ordinary file paths and URLs are never claimed, whatever GDAL could do with them: xarray tries this engine before its zarr engine, kerchunk and rioxarray’s rasterio engine, so claiming store.zarr or image.tif would take those files away from the engine the user expects, and claiming file.nc when no netCDF engine is installed would hide xarray’s missing-dependency error. Pass engine="gdalxarray" to open such sources.

A string in one of those forms is claimed only if it opens the way open_dataset opens it by default, with the multidim API, so a claimed source is one the default open can read.

open_dataset

GDALBackendEntrypoint.open_dataset(
    filename_or_obj,
    *,
    drop_variables=None,
    chunks=None,
    multidim=True,
    group=None,
    band_as_dim=True,
    config_options=None,
    mask_and_scale=None,
    decode_times=None,
    decode_timedelta=None,
    use_cftime=None,
    concat_characters=None,
    decode_coords=None,
)

Open a dataset using GDAL.

Parameters

Name Type Description Default
filename_or_obj str Path or GDAL-recognised URI (/vsicurl/, /vsis3/, vrt://, ZARR:, NETCDF:, /vsiicechunk/...). required
drop_variables iterable of hashable Variables to omit from the returned Dataset. None
chunks dict Chunk sizes for Dask arrays. None (default) returns a lazy non-Dask Dataset; {} uses GDAL’s native block sizes; an explicit mapping like {"y": 256, "x": 256} is honoured (dimensions not named keep a single chunk). Chunking is delegated to Dataset.chunk so chunked arrays are created by xarray’s active chunk manager rather than by this backend (issue #31); dask is only required when chunks is not None. None
multidim bool If True, use GDAL’s multidimensional API (OpenEx + OF_MULTIDIM_RASTER). If False, use the classic raster API. True
group str Group path for multidim datasets (e.g. "/group/subgroup"). Leading/trailing slashes are tolerated. None
band_as_dim bool Classic-raster only. If True, bands become an xarray band dimension on a single band_data DataArray (the rioxarray- compatible idiom). If False, each band becomes a separate data variable named after its description (or band_N). The True default suits multispectral imagery; False is preferable when bands carry semantically distinct quantities. Bands reporting differing nodata/scale/offset cannot be CF-decoded as one variable: values are returned raw with per-band metadata in band_nodata/band_scale_factor/band_add_offset coordinates and a warning is emitted (use band_as_dim=False to decode each band independently). True
config_options dict GDAL configuration options, e.g. {"GDAL_HTTP_MAX_RETRY": "3", "GDAL_HTTP_RETRY_DELAY": "5"}. Applied thread-locally around the open and around every subsequent read, including per-thread reopens under dask (issue #34) and reads on distributed workers after unpickling, then unset again, so concurrent opens with different options do not interfere. Values are stringified. Not applied during engine auto-detection (guess_can_open). None
mask_and_scale bool If True (default), apply CF mask/scale decoding: nodata becomes NaN and scale_factor/add_offset are applied, with the original values recorded in each variable’s encoding. If False, return raw values with the CF attributes left in attrs. None