File tree Expand file tree Collapse file tree 4 files changed +19
-5
lines changed
Expand file tree Collapse file tree 4 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 1+ # GitHub syntax highlighting
2+ pixi.lock linguist-language =YAML linguist-generated =true
Original file line number Diff line number Diff line change @@ -128,3 +128,6 @@ cython_debug/
128128
129129# MacOS
130130.DS_Store
131+
132+ # pixi environments
133+ .pixi
Original file line number Diff line number Diff 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 ,
Original file line number Diff line number Diff 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' ,
You can’t perform that action at this time.
0 commit comments