0

I am getting errors exporting and getting the image URL for an image. Here is the image I am trying to export:

    img = an_image.add(another_img)

I have tried 'ee.batch.Export.image.toDrive'

    export_params = {
    "image": img,
    "description": 'LST',
    "folder": "imageEE",
    "scale": 10,
    "region": geometry,
    "crs": 'EPSG:4326',
    "maxPixels": 1e12,
    "fileFormat": 'GeoTIFF',
    "formatOptions": {
    "cloudOptimized": True
    }}

# Export the image to Google Drive
task = ee.batch.Export.image.toDrive(**export_params)
task.start()

and I have tried 'ee.getDownloadURL()' as per the example given: https://github.com/google/earthengine-api/blob/master/python/examples/py/Image/download.py

URL = img.getDownloadUrl({
    'name': 'final_img',
    'scale': 10,
    'crs': 'EPSG:4326',
    'region': geometry
})

Both cases give me the same/similar errors to do with the image input

Error: ImageCollection.fromImages, argument 'images': Invalid type. Expected type: 
List<Image<unknown bands>>. Actual type: Image<[B1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, 
B10, B11, B12, QA10, QA20, QA60]>. (Error code: 3)
enter code here

The same code exports the image when using the Google Earth Engine editor in JavaScript so I need to know how to pass the image parameter in Python. The task gets submitted (can see it in my task manager ) but gives me the error given above so it does not get saved.

<<< updated example >>>

full error for the getDownloadURL case:

Traceback (most recent call last):
  File "C:\Users\user\miniconda3\lib\site-packages\ee\data.py", line 337, in _execute_cloud_call
    return call.execute(num_retries=num_retries)
  File "C:\Users\user\miniconda3\lib\site-packages\googleapiclient\_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "C:\Users\user\miniconda3\lib\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/v1alpha/projects/earthengine-legacy/thumbnails?fields=name&alt=json returned "ImageCollection.fromImages, argument 'images': Invalid type.
Expected type: List<Image<unknown bands>>.
Actual type: Image<[SR_B1, SR_B2, SR_B3, SR_B4, SR_B5, SR_B6, SR_B7, SR_QA_AEROSOL, ST_B10, ST_ATRAN, ST_CDIST, ST_DRAD, ST_EMIS, ST_EMSD, ST_QA, ST_TRAD, ST_URAD, QA_PIXEL, QA_RADSAT]>.". Details: "ImageCollection.fromImages, argument 'images': Invalid type.
Expected type: List<Image<unknown bands>>.
Actual type: Image<[SR_B1, SR_B2, SR_B3, SR_B4, SR_B5, SR_B6, SR_B7, SR_QA_AEROSOL, ST_B10, ST_ATRAN, ST_CDIST, ST_DRAD, ST_EMIS, ST_EMSD, ST_QA, ST_TRAD, ST_URAD, QA_PIXEL, QA_RADSAT]>.">

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\OneDrive\RP3\Code\thermal\final\code\main.py", line 20, in <module>
    main()
  File "C:\Users\user\OneDrive\RP3\Code\thermal\final\code\main.py", line 16, in main
    recent_thermal_img = model(l_collection_recentimg,  s2_collection_recentimg, extent)
  File "C:\Users\user\OneDrive\RP3\Code\thermal\final\code\allmodel.py", line 185, in model
    path = img.getDownloadUrl({
  File "C:\Users\user\miniconda3\lib\site-packages\ee\deprecation.py", line 32, in Wrapper
    return func(*args, **kwargs)
  File "C:\Users\user\miniconda3\lib\site-packages\ee\image.py", line 469, in getDownloadURL
    return data.makeDownloadUrl(data.getDownloadId(request))
  File "C:\Users\user\miniconda3\lib\site-packages\ee\data.py", line 1159, in getDownloadId
    result = _execute_cloud_call(
  File "C:\Users\user\miniconda3\lib\site-packages\ee\data.py", line 339, in _execute_cloud_call
    raise _translate_cloud_exception(e)
ee.ee_exception.EEException: ImageCollection.fromImages, argument 'images': Invalid type.
Expected type: List<Image<unknown bands>>.
Actual type: Image<[SR_B1, SR_B2, SR_B3, SR_B4, SR_B5, SR_B6, SR_B7, SR_QA_AEROSOL, ST_B10, ST_ATRAN, ST_CDIST, ST_DRAD, ST_EMIS, ST_EMSD, ST_QA, ST_TRAD, ST_URAD, QA_PIXEL, QA_RADSAT]>.

full error for the export to drive case:

same as before

more code for making the image:

    ```...    

        im1 = L8_LST_30m.subtract(L8_LST_MODEL)

palette = ['040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6', \
            '0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef'] \

# Define a gaussian kernel
gaussian = ee.Kernel.gaussian(**{
    'radius': 2, 
    'units': 'pixels'
})

im2 = im1.resample("bicubic").convolve(gaussian)

visParam_residuals = {
    'min': -10,
    'max': 9,
    'palette': ['blue', 'yellow', 'red']
}

im3 = ee.Image(inter2).add(sNDVI.multiply(S2_1)) \
            .add(sNDBI.multiply(S2_2)).add(sNDWI.multiply(S2_3))


img = im3.add(im2)```

the inputs to the model function are strings:

LANDSAT/LC09/C02/T1_L2/LC09_178027_20230314
COPERNICUS/S2/20230327T083601_20230327T084622_T36TXT

which get converted to collections and then clipped or first() depending on what needs to be done.

2
  • Please post a complete example. The error clearly indicates the problem is elsewhere in your script. Apr 7, 2023 at 11:56
  • @NoelGorelick I added some additional info, let me know if you need more
    – Reece
    Apr 7, 2023 at 13:21

1 Answer 1

0

It looks like the main error you are getting:

Error: ImageCollection.fromImages, argument 'images': Invalid type. Expected type: 
List<Image<unknown bands>>. Actual type: Image<[B1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, 
B10, B11, B12, QA10, QA20, QA60]>. (Error code: 3)

comes from an incorrect use of ee.ImageCollection.fromImages .

Consider the following example:

img1 = ee.Image(0)
img2 = ee.Image(1)
img3 = ee.Image(2)

# Error: passing a single image instead of a list of images:
print(
ee.ImageCollection.fromImages(img1).getInfo()
)

# Ok: passing a list consisting of a single image:
print(
ee.ImageCollection.fromImages([img1]).getInfo()
)

# Ok: passing a list consisting of more than one images:
print(
ee.ImageCollection.fromImages([img1,img2,img3]).getInfo()
)

Example in the code editor: https://code.earthengine.google.com/89b7cbcecee53f10b21dcc12b19ff342

As you didn't post a complete minimal working example, I can only guess that this is the error in your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.