Skip to content

io

titiler.xarray.io

titiler.xarray.io

Reader

Bases: XarrayReader

Reader: Open Zarr file and access DataArray.

__attrs_post_init__

__attrs_post_init__()

Set bounds and CRS.

__exit__

__exit__(exc_type, exc_value, traceback)

Support using with Context Managers.

close

close()

Close xarray dataset.

_arrange_dims

_arrange_dims(da: DataArray) -> DataArray

Arrange coordinates and time dimensions.

An rioxarray.exceptions.InvalidDimensionOrder error is raised if the coordinates are not in the correct order time, y, and x. See: corteva/rioxarray?674

We conform to using x and y as the spatial dimension names..

get_variable

get_variable(
    ds: Dataset, variable: str, datetime: Optional[str] = None, drop_dim: Optional[str] = None
) -> DataArray

Get Xarray variable as DataArray.

Parameters:

  • ds (Dataset) –

    Xarray Dataset.

  • variable (str) –

    Variable to extract from the Dataset.

  • datetime (str, default: None ) –

    datetime to select from the DataArray.

  • drop_dim (str, default: None ) –

    DataArray dimension to drop in form of {dimension}={value}.

Returns:

  • DataArray

    xarray.DataArray: 2D or 3D DataArray.

xarray_open_dataset

xarray_open_dataset(
    src_path: str, group: Optional[str] = None, decode_times: bool = True
) -> Dataset

Open Xarray dataset with fsspec.

Parameters:

  • src_path (str) –

    dataset path.

  • group ((Optional, str), default: None ) –

    path to the netCDF/Zarr group in the given file to open given as a str.

  • decode_times (bool, default: True ) –

    If True, decode times encoded in the standard NetCDF datetime format into datetime objects. Otherwise, leave them encoded as numbers.

Returns:

  • Dataset

    xarray.Dataset