diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 3f8d40910cd..09eec8b1d94 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -69,9 +69,13 @@ Bug fixes (:issue:`2240`) By `Keisuke Fujii `_. +- Fix a bug that caused some indexing operations on arrays opened with + ``open_rasterio`` to error (:issue:`2454`). + By `Stephan Hoyer `_. + .. _whats-new.0.10.9: -v0.10.9 (21 September 2019) +v0.10.9 (21 September 2018) --------------------------- This minor release contains a number of backwards compatible enhancements. @@ -79,7 +83,7 @@ This minor release contains a number of backwards compatible enhancements. Announcements of note: - Xarray is now a NumFOCUS fiscally sponsored project! Read - `the anouncment `_ + `the anouncement `_ for more details. - We have a new :doc:`roadmap` that outlines our future development plans. diff --git a/xarray/backends/rasterio_.py b/xarray/backends/rasterio_.py index 5221cf0e913..d2336a5b9f2 100644 --- a/xarray/backends/rasterio_.py +++ b/xarray/backends/rasterio_.py @@ -95,7 +95,7 @@ def _get_indexer(self, key): if isinstance(key[1], np.ndarray) and isinstance(key[2], np.ndarray): # do outer-style indexing - np_inds[1:] = np.ix_(*np_inds[1:]) + np_inds[-2:] = np.ix_(*np_inds[-2:]) return band_key, tuple(window), tuple(squeeze_axis), tuple(np_inds) diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py index 8b469761ccd..8ab75d6fd9c 100644 --- a/xarray/tests/test_backends.py +++ b/xarray/tests/test_backends.py @@ -2928,6 +2928,10 @@ def test_indexing(self): assert_allclose(expected.isel(**ind), actual.isel(**ind)) assert not actual.variable._in_memory + ind = {'band': 0, 'x': np.array([0, 0]), 'y': np.array([1, 1, 1])} + assert_allclose(expected.isel(**ind), actual.isel(**ind)) + assert not actual.variable._in_memory + # minus-stepped slice ind = {'band': np.array([2, 1, 0]), 'x': slice(-1, None, -1), 'y': 0}