diff --git a/xee/ext.py b/xee/ext.py index 127047d..c54b1cc 100644 --- a/xee/ext.py +++ b/xee/ext.py @@ -278,9 +278,16 @@ def get_info(self) -> Dict[str, Any]: rpcs.append(('projection', self.projection)) if isinstance(self.geometry, ee.Geometry): - rpcs.append(('bounds', self.geometry.bounds())) + rpcs.append(('bounds', self.geometry.bounds(1, proj=self.projection))) else: - rpcs.append(('bounds', self.image_collection.first().geometry().bounds())) + rpcs.append( + ( + 'bounds', + self.image_collection.first() + .geometry() + .bounds(1, proj=self.projection), + ) + ) # TODO(#29, #30): This RPC call takes the longest time to compute. This # requires a full scan of the images in the collection, which happens on the @@ -293,14 +300,16 @@ def get_info(self) -> Dict[str, Any]: # client-side. Ideally, this would live behind a xarray-backend-specific # feature flag, since it's not guaranteed that data is this consistent. columns = ['system:id', self.primary_dim_property] - rpcs.append(( - 'properties', + rpcs.append( ( - self.image_collection.reduceColumns( - ee.Reducer.toList().repeat(len(columns)), columns - ).get('list') - ), - )) + 'properties', + ( + self.image_collection.reduceColumns( + ee.Reducer.toList().repeat(len(columns)), columns + ).get('list') + ), + ) + ) info = ee.List([rpc for _, rpc in rpcs]).getInfo() diff --git a/xee/ext_integration_test.py b/xee/ext_integration_test.py index 6a29cf7..4b6a35f 100644 --- a/xee/ext_integration_test.py +++ b/xee/ext_integration_test.py @@ -269,6 +269,32 @@ def __getitem__(self, params): self.assertEqual(getter.count, 3) + def test_geometry_bounds_with_and_without_projection(self): + image = ( + ee.ImageCollection('LANDSAT/LC08/C01/T1') + .filterDate('2017-01-01', '2017-01-03') + .first() + ) + point = ee.Geometry.Point(-40.2414893624401, 105.48790177216375) + distance = 311.5 + scale = 5000 + projection = ee.Projection('EPSG:4326', [1, 0, 0, 0, -1, 0]).atScale(scale) + image = image.reproject(projection) + + geometry = point.buffer(distance, proj=projection).bounds(proj=projection) + + data_store = xee.EarthEngineStore( + ee.ImageCollection(image), + projection=image.projection(), + geometry=geometry, + ) + data_store_bounds = data_store.get_info['bounds'] + + self.assertNotEqual(geometry.bounds().getInfo(), data_store_bounds) + self.assertEqual( + geometry.bounds(1, proj=projection).getInfo(), data_store_bounds + ) + def test_getitem_kwargs(self): arr = xee.EarthEngineBackendArray('B4', self.store) self.assertEqual(arr.store.getitem_kwargs['initial_delay'], 1500)