google / Xee

An Xarray extension for Google Earth Engine
Apache License 2.0
243 stars 28 forks source link

unable to open LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318 #80

Closed raybellwaves closed 9 months ago

raybellwaves commented 11 months ago

Thanks a lot for your work here @alxmrs !

I just started playing with this and I wanted to understand the scale parameter. I came across some information at https://developers.google.com/earth-engine/guides/scale

I was thinking what a python version (using xee) of the JaveScript code snippet on the page would look like:

var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318').select('B4');

var printAtScale = function(scale) {
  print('Pixel value at '+scale+' meters scale',
    image.reduceRegion({
      reducer: ee.Reducer.first(),
      geometry: image.geometry().centroid(),
      // The scale determines the pyramid level from which to pull the input
      scale: scale
  }).get('B4'));
};

printAtScale(10); // 0.10394100844860077
printAtScale(30); // 0.10394100844860077
printAtScale(50); // 0.09130698442459106
printAtScale(70); // 0.1150854229927063
printAtScale(200); // 0.102478988468647
printAtScale(500); // 0.09072770178318024

I'm having trouble opening the asset LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318.

I've tried

i = ee.Image("LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318")
ds = xarray.open_dataset(i, engine="ee")

and got

>>> ds = xarray.open_dataset(i, engine="ee")
Traceback (most recent call last):
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/ee/data.py", line 354, in _execute_cloud_call
    return call.execute(num_retries=num_retries)
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/googleapiclient/http.py", line 938, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://earthengine-highvolume.googleapis.com/v1/projects/ee-rayjohnbell0/value:compute?prettyPrint=false&alt=json returned "ImageCollection.load: ImageCollection asset 'ee.Image({  "functionInvocationValue": {    "functionName": "Image.load",    "arguments": {      "id": {        "constantValue": "LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318"      }    }  }})' not found (does not exist or caller does not have access).". Details: "ImageCollection.load: ImageCollection asset 'ee.Image({  "functionInvocationValue": {    "functionName": "Image.load",    "arguments": {      "id": {        "constantValue": "LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318"      }    }  }})' not found (does not exist or caller does not have access).">

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/xarray/backends/api.py", line 573, in open_dataset
    backend_ds = backend.open_dataset(
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/xee/ext.py", line 928, in open_dataset
    store = EarthEngineStore.open(
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/xee/ext.py", line 149, in open
    return cls(
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/xee/ext.py", line 186, in __init__
    self.n_images = self.get_info['size']
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/functools.py", line 981, in __get__
    val = self.func(instance)
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/xee/ext.py", line 290, in get_info
    info = ee.List([rpc for _, rpc in rpcs]).getInfo()
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/ee/computedobject.py", line 105, in getInfo
    return data.computeValue(self)
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/ee/data.py", line 1021, in computeValue
    return _execute_cloud_call(
  File "/Users/ray/miniforge3/envs/test_env/lib/python3.10/site-packages/ee/data.py", line 356, in _execute_cloud_call
    raise _translate_cloud_exception(e)  # pylint: disable=raise-missing-from
ee.ee_exception.EEException: ImageCollection.load: ImageCollection asset 'ee.Image({  "functionInvocationValue": {    "functionName": "Image.load",    "arguments": {      "id": {        "constantValue": "LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318"      }    }  }})' not found (does not exist or caller does not have access).

The Trackback eludes to access issues but I can access other LANDSAT_LC08_C02_T1_TOA data:

ic = ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA")
ds = xarray.open_dataset(ic, engine="ee")
mahrsee1997 commented 11 months ago

Hi @raybellwaves,

The issue is xee expects ImageCollection as input so you can create a IC out of image & pass it on...

i = ee.ImageCollection(ee.Image("LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318"))
ds = xarray.open_dataset(i, engine='ee')

For more information on parameters you can have a look at this:

import xee
help(xee.EarthEngineBackendEntrypoint.open_dataset)
mahrsee1997 commented 9 months ago

Not an issue. Added example in PR https://github.com/google/Xee/pull/84 for handling such case.