Skip to content

ENH: Add ability to load bands as data_vars #296

Closed

Description

@snowman2

@alexamici brought this up in #197 and has been something I have thought about for a while and haven't come up with a great solution yet.

xarray-gdal implementation: https://github.com/bopen/xarray-gdal/blob/main/xarray_gdal/xarray_plugin.py

Benefits:

Why hasn't it been done already?

  • Backwards compatibility/consistency with xarray.open_rasterio
  • Loading it as a DataArray allows open_rasterio to work with multidimensional files where the band is a coordinate (time).
  • The coordinate mechanism provides a nice interface for selecting the band you are interested in by an index rds.sel(band=1).

It may make sense to have an option such as band_as_variable where you can toggle this mode on.

Activity

  1. ashleysommer commented on Mar 3, 2022

    @ashleysommer

    This looks like a really useful feature (and directly related to my issue in #484)

    In the gdalbuildvrt tool, you can pass the option -separate that puts each file into a separate band in the VRT file (and in this case each source file can have a different dtype).

    So I propose, if you make this an optional behavior, the option could be called separate.

  2. snowman2 commented on May 12, 2022

    @snowman2
    MemberAuthor
  3. snowman2 commented on Nov 2, 2022

    @snowman2
    MemberAuthor

    For those interested, see #600.

  4. added this to the 0.13.0 milestone on Nov 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalIdea for a new feature.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions