Skip to main content

Xarray plugin for TiTiler.

Project description

titiler.xarray

Adds support for Xarray Dataset (NetCDF/Zarr) in Titiler.

Installation

python -m pip install -U pip

# From Pypi
python -m pip install "titiler.xarray[full]"

# Or from sources
git clone https://github.com/developmentseed/titiler.git
cd titiler && python -m pip install -e src/titiler/core -e "src/titiler/xarray[full]"

Installation options

Default installation for titiler.xarray DOES NOT include fsspec or any storage's specific dependencies (e.g s3fs) nor engine dependencies (zarr, h5netcdf). This is to ease the customization and deployment of user's applications. If you want to use the default's dataset reader you will need to at least use the [minimal] dependencies (e.g python -m pip install "titiler.xarray[minimal]").

Here is the list of available options:

  • full: zarr, h5netcdf, fsspec, s3fs, aiohttp, gcsfs
  • minimal: zarr, h5netcdf, fsspec
  • gcs: gcsfs
  • s3: s3fs
  • http: aiohttp

How To

from fastapi import FastAPI

from titiler.xarray.extensions import VariablesExtension
from titiler.xarray.factory import TilerFactory

app = FastAPI(
    openapi_url="/api",
    docs_url="/api.html",
    description="""Xarray based tiles server for MultiDimensional dataset (Zarr/NetCDF).

---

**Documentation**: <a href="https://developmentseed.org/titiler/" target="_blank">https://developmentseed.org/titiler/</a>

**Source Code**: <a href="https://github.com/developmentseed/titiler" target="_blank">https://github.com/developmentseed/titiler</a>

---
    """,
)

md = TilerFactory(
    router_prefix="/md",
    extensions=[
        VariablesExtension(),
    ],
)
app.include_router(md.router, prefix="/md", tags=["Multi Dimensional"])

Package structure

titiler/
 └── xarray/
    ├── tests/                   - Tests suite
    └── titiler/xarray/          - `xarray` namespace package
        ├── dependencies.py      - titiler-xarray dependencies
        ├── extensions.py        - titiler-xarray extensions
        ├── io.py                - titiler-xarray Readers
        └── factory.py           - endpoints factory

Custom Dataset Opener

A default Dataset IO is provided within titiler.xarray.Reader class but will require optional dependencies (fsspec, zarr, h5netcdf, ...) to be installed with python -m pip install "titiler.xarray[full]". Dependencies are optional so the entire package size can be optimized to only include dependencies required by a given application.

Example:

requirements:

  • titiler.xarray (base)
  • h5netcdf
from typing import Callable
import attr
from fastapi import FastAPI
from titiler.xarray.io import Reader
from titiler.xarray.extensions import VariablesExtension
from titiler.xarray.factory import TilerFactory

import xarray
import h5netcdf  # noqa

# Create a simple Custom reader, using `xarray.open_dataset` opener
@attr.s
class CustomReader(Reader):
    """Custom io.Reader using xarray.open_dataset opener."""
    # xarray.Dataset options
    opener: Callable[..., xarray.Dataset] = attr.ib(default=xarray.open_dataset)


# Create FastAPI application
app = FastAPI(openapi_url="/api", docs_url="/api.html")

# Create custom endpoints with the CustomReader
md = TilerFactory(
    reader=CustomReader,
    router_prefix="/md",
    extensions=[
        # we also want to use the simple opener for the Extension
        VariablesExtension(dataset_opener=xarray.open_dataset),
    ],
)

app.include_router(md.router, prefix="/md", tags=["Multi Dimensional"])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

titiler_xarray-0.22.4.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

titiler_xarray-0.22.4-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file titiler_xarray-0.22.4.tar.gz.

File metadata

  • Download URL: titiler_xarray-0.22.4.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for titiler_xarray-0.22.4.tar.gz
Algorithm Hash digest
SHA256 fbf9f633c7219701aff72527ca66b22d4a0719eff1f0e2fd976a7c1c5f470818
MD5 4427590f6699397b5da318bc523a9f2a
BLAKE2b-256 75fe0cf139a2c70ac12958bd23d8818011a7dd627b5430df2451131ef776d72d

See more details on using hashes here.

File details

Details for the file titiler_xarray-0.22.4-py3-none-any.whl.

File metadata

File hashes

Hashes for titiler_xarray-0.22.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1a27f35e537b8b3aba2a87e861d7124c3b15c56fb9768c91f5c69c43339bfcd3
MD5 d2c3a49e7ef9d6758ef24a0483c6444b
BLAKE2b-256 77251e8bf04e59593367e0fefc78c3f376e78bbdbd9d2fe07ac4dfa41b687745

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page