Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with export of ImageCollection #263

Open
tabea-schultestrathaus opened this issue Apr 16, 2024 · 3 comments
Open

Problem with export of ImageCollection #263

tabea-schultestrathaus opened this issue Apr 16, 2024 · 3 comments
Labels
kind: bug Something isn't working tag: regression A regression occured during V0 to V1 release

Comments

@tabea-schultestrathaus
Copy link

tabea-schultestrathaus commented Apr 16, 2024

Hi there,

I have some issues with downloading an ImageCollection and I would appreciate any help! I'm following an earlier tutorial from this community.

Here's my code:

import ee
import random
from geetools import batch

ee.Authenticate(auth_mode='localhost')
ee.Initialize(project='ee-user')

seed = random.randint(0, 10000)

collection = (ee.ImageCollection('COPERNICUS/S2_SR_HARMONIZED')
              .filterDate('2023-01-01', '2023-01-31')
              .filter(ee.Filter.stringContains('MGRS_TILE', '20M'))
              .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 10))
              .randomColumn('randomKey', seed)
              .sort('randomKey')
              .limit(3)
              .select(['B2', 'B3', 'B4', 'B8']))

print('Number of images', collection.size().getInfo())

size = collection.size().getInfo()
clist = collection.toList(size)
for i in range(size):
    image = ee.Image(clist.get(i))
    iid = image.id().getInfo()
    name = 'jan_'+iid
    print('downloading '+ name)
    batch.image.toLocal(image, name)

And here's the error:

(user) [user"user]$ /user/export.py
Number of images 3
downloading jan_20230126T144729_20230126T145426_T20MKU
Traceback (most recent call last):
  File "/user/data.py", line 402, in _execute_cloud_call
    return call.execute(num_retries=num_retries)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/lib/python3.12/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/lib/python3.12/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.googleapis.com/v1/projects/ee-user/value:compute?prettyPrint=false&alt=json returned "Image.bandNames, argument 'image': Invalid type.
Expected type: Image<unknown bands>.
Actual type: Feature.". Details: "Image.bandNames, argument 'image': Invalid type.
Expected type: Image<unknown bands>.
Actual type: Feature.">

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/user/export.py", line 28, in <module>
    batch.image.toLocal(image, name)
  File "/user/lib/python3.12/site-packages/geetools/batch/image.py", line 37, in toLocal
    scale = scale if scale else int(tools.image.minscale(image).getInfo())
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/lib/python3.12/site-packages/ee/computedobject.py", line 107, in getInfo
    return data.computeValue(self)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/lib/python3.12/site-packages/ee/data.py", line 1107, in computeValue
    return _execute_cloud_call(
           ^^^^^^^^^^^^^^^^^^^^
  File "/user/lib/python3.12/site-packages/ee/data.py", line 404, in _execute_cloud_call
    raise _translate_cloud_exception(e)  # pylint: disable=raise-missing-from
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ee.ee_exception.EEException: Image.bandNames, argument 'image': Invalid type.
Expected type: Image<unknown bands>.
Actual type: Feature.
@12rambau
Copy link
Member

This script is not compatible with version 1.0 of the lib as exportation has not been refactored yet. Could you try using 0.6.14 ?
Alternatively can you look at my answer in #256 ?

@tabea-schultestrathaus
Copy link
Author

Hi, thanks for your reply! I already downgraded to 0.6.14. Is it really a problem with batch?

@12rambau
Copy link
Member

I think yes,
maybe the latest changes to the tools module have conflict in the batch context, or the collection you have is a featureCollection nwhich sounds strange.

The problem is that there was no tests before so I'm building them on the spot every time I refactor an existing method. There are many cases where I need multiple iteration to cover all the edge cases. The v1 of the lib will eventually be more stable but i still need to work on batch

@12rambau 12rambau added kind: bug Something isn't working tag: regression A regression occured during V0 to V1 release labels Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working tag: regression A regression occured during V0 to V1 release
Projects
None yet
Development

No branches or pull requests

2 participants