Skip to content

io

titiler.xarray.io

titiler.xarray.io

FsReader

Bases: Reader

Reader with fs_open_dataset opener

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.

selector

Bases: TypedDict

STAC Item.

_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..

_parse_dsl

_parse_dsl(sel: list[str] | None) -> list[selector]

Parse sel DSL into dictionary.

Parameters:

  • sel (list of str) –

    List of Xarray Indexes.

Returns:

  • list ( list[selector] ) –

    list of dimension/values/method.

fs_open_dataset

fs_open_dataset(
    src_path: str,
    group: str | None = None,
    decode_times: bool = True,
    decode_coords: str = "all",
    **kwargs
) -> 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

get_variable

get_variable(ds: Dataset, variable: str, sel: list[str] | None = None) -> DataArray

Get Xarray variable as DataArray.

Parameters:

  • ds (Dataset) –

    Xarray Dataset.

  • variable (str) –

    Variable to extract from the Dataset.

  • sel (list of str, default: None ) –

    List of Xarray Indexes.

Returns:

  • DataArray

    xarray.DataArray: 2D or 3D DataArray.

open_zarr cached

open_zarr(
    src_path: str,
    group: str | None = None,
    decode_times: bool = True,
    decode_coords: str = "all",
    infer_region: bool = True,
    **kwargs: Any
) -> 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