Skip to content

Commit

Permalink
BUG: Add band_as_variable to xarray plugin (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
snowman2 authored Nov 7, 2022
1 parent 59e97af commit 5952536
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions rioxarray/xarray_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def open_dataset(
default_name="band_data",
decode_times=True,
decode_timedelta=None,
band_as_variable=False,
open_kwargs=None,
):
if open_kwargs is None:
Expand All @@ -65,6 +66,7 @@ def open_dataset(
default_name=default_name,
decode_times=decode_times,
decode_timedelta=decode_timedelta,
band_as_variable=band_as_variable,
**open_kwargs,
)
if isinstance(rds, xr.DataArray):
Expand Down
6 changes: 4 additions & 2 deletions test/integration/test_integration__io.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,11 @@ def test_utm():
assert "y" not in rioda.coords


def test_band_as_variable():
def test_band_as_variable(open_rasterio):
with create_tmp_geotiff() as (tmp_file, expected):
with rioxarray.open_rasterio(tmp_file, band_as_variable=True) as riods:
with open_rasterio(
tmp_file, band_as_variable=True, mask_and_scale=False
) as riods:
for band in (1, 2, 3):
band_name = f"band_{band}"
assert_allclose(riods[band_name], expected.sel(band=band).drop("band"))
Expand Down

0 comments on commit 5952536

Please sign in to comment.