Skip to content

Commit 5ce8db6

Browse files
author
Xee authors
committed
Merge pull request #191 from tylere:issue_190
PiperOrigin-RevId: 697703491
2 parents 9c34203 + 5182b88 commit 5ce8db6

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# GitHub syntax highlighting
2+
pixi.lock linguist-language=YAML linguist-generated=true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,6 @@ cython_debug/
128128

129129
# MacOS
130130
.DS_Store
131+
132+
# pixi environments
133+
.pixi

xee/ext.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,11 +1122,12 @@ def open_dataset(
11221122
if ee.data.getUserAgent() != user_agent:
11231123
ee.data.setUserAgent(user_agent)
11241124

1125-
collection = (
1126-
filename_or_obj
1127-
if isinstance(filename_or_obj, ee.ImageCollection)
1128-
else ee.ImageCollection(self._parse(filename_or_obj))
1129-
)
1125+
if isinstance(filename_or_obj, ee.ImageCollection):
1126+
collection = filename_or_obj
1127+
elif isinstance(filename_or_obj, ee.Image):
1128+
collection = ee.ImageCollection(filename_or_obj)
1129+
else:
1130+
collection = ee.ImageCollection(self._parse(filename_or_obj))
11301131

11311132
store = EarthEngineStore.open(
11321133
collection,

xee/ext_integration_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,14 @@ def test_open_dataset__n_images(self):
382382

383383
self.assertLen(ds.time, 1)
384384

385+
def test_open_dataset_image_to_imagecollection(self):
386+
"""Ensure that opening an ee.Image is the same as opening a single image ee.ImageCollection."""
387+
img = ee.Image('CGIAR/SRTM90_V4')
388+
ic = ee.ImageCollection(img)
389+
ds1 = xr.open_dataset(img, engine='ee')
390+
ds2 = xr.open_dataset(ic, engine='ee')
391+
self.assertTrue(ds1.identical(ds2))
392+
385393
def test_can_chunk__opened_dataset(self):
386394
ds = xr.open_dataset(
387395
'NASA/GPM_L3/IMERG_V07',

0 commit comments

Comments
 (0)