cog3pio icon indicating copy to clipboard operation
cog3pio copied to clipboard

:sparkles: Implement cog3pio xarray BackendEntrypoint

Open weiji14 opened this issue 3 months ago • 0 comments

Allow 'cog3pio' to be used as an engine in xarray.open_dataarray and xarray.open_dataset!

Usage (Python):

import xarray as xr

with xr.open_dataarray(
    filename_or_obj="https://github.com/cogeotiff/rio-tiler/raw/6.4.1/tests/fixtures/cog_nodata_nan.tif",
    engine="cog3pio",
) as da:
    assert da.sizes == {'band': 1, 'y': 549, 'x': 549}
    assert da.dtype == "float32"

TODO:

  • [x] Initial implementation of xarray BackendEntrypoint
  • [x] Decode xy coordinates, depend on changes at https://github.com/georust/geo/pull/1159
  • [x] Benchmark cog3pio engine vs rioxarray engine
  • [ ] Document example usage in main README.md and docstrings
  • [ ] etc

TODO in the future:

  • [ ] Handle NaN values in GeoTIFF properly

References:

  • https://docs.xarray.dev/en/v2024.02.0/internals/how-to-add-new-backend.html

weiji14 avatar Mar 25 '24 22:03 weiji14