leftfield-geospatial / geedim

Search, composite, and download Google Earth Engine imagery.
https://geedim.readthedocs.io
Apache License 2.0
75 stars 11 forks source link

specific Sentinel2 MaskedImage fails with "Image.rename: Parameter 'input' is required." #24

Open iona5 opened 1 week ago

iona5 commented 1 week ago

I am having trouble using geedim with a specific image from the harmonized sentinel 2 collection, namely COPERNICUS/S2_SR_HARMONIZED/20230809T201859_20230809T201853_T10WEE. Whenever this images comes up in a search collection, i cannot process the collection for example to extract data with error: Image.rename: Parameter 'input' is required.

I do not know whats specifically different with this image. I drilled that down to a problem with the processing geedim applies to the image when using the region parameter but i cannot find the problem itself.

i am using a conda environment with

python                    3.11.9               he1021f5_0
earthengine-api           0.1.408            pyhd8ed1ab_0    conda-forge
geedim                    1.8.0              pyhd8ed1ab_0    conda-forge

I tested it with a bunch of images in a specific region and different region polygons. I made an example using getInfo() on the resulting image to trigger the processing, but it applies to any other client-side GEE method including geedims download():

import ee
import geedim

ee.Initialize()

poly_coords1 = [
    [-121.30224921178123,71.77255565243381],
    [-121.69226386021873,71.58260352221238],
    [-120.87378241490623,71.52698680217173],
    [-120.86828925084373,71.70370209220792],
    [-121.30224921178123,71.77255565243381],
]
poly_coords2 = [
    [-121.65930487584373,71.92795376863671],
    [-121.70874335240623,71.82200371558541],
    [-121.16492011021873,71.84769170326668],
    [-121.45056464146873,71.90237555398673],
    [-121.65930487584373,71.92795376863671],
]
poly_coords3 = [
    [-120.97265936803123,71.98070472145938],
    [-120.98913886021873,71.73784463314388],
    [-120.08276678990623,71.74472884706717],
    [-120.28052069615623,71.98750044350669],
    [-120.97265936803123,71.98070472145938],
]

bounds = [
    ee.Geometry.Polygon(list(poly_coords1), proj=None, evenOdd=False),
    ee.Geometry.Polygon(list(poly_coords2), proj=None, evenOdd=False),
    ee.Geometry.Polygon(list(poly_coords3), proj=None, evenOdd=False),
]

images = [
    "20230801T200901_20230801T200857_T10WEE",
    "20230802T202849_20230802T202847_T10WEE",
    "20230803T195859_20230803T200054_T10WEE",
    "20230804T201851_20230804T201853_T10WEE",
    "20230804T201851_20230804T202447_T10WEE",
    "20230806T200859_20230806T201056_T10WEE",
    "20230807T202851_20230807T203151_T10WEE",
    "20230808T195901_20230808T195945_T10WEE",
    "20230811T200901_20230811T200857_T10WEE",
    "20230812T202849_20230812T202934_T10WEE",
    "20230813T195859_20230813T195900_T10WEE",
    "20230814T201851_20230814T202428_T10WEE",
    "20230809T201859_20230809T201853_T10WEE", # <- this one is broken
]

for i,poly in enumerate(bounds):
    print(f"Polygon {i}:")
    for image_id in images:
        try:
            ( geedim.MaskedImage
                .from_id("COPERNICUS/S2_SR_HARMONIZED/" + image_id, region=poly)
                .ee_image.getInfo()
            )
            print(f" {image_id} -> √")
        except ee.ee_exception.EEException as e:
            print(f" {image_id} -> error: {e}")

which produces

Polygon 0:
 20230801T200901_20230801T200857_T10WEE -> √
 20230802T202849_20230802T202847_T10WEE -> √
 20230803T195859_20230803T200054_T10WEE -> √
 20230804T201851_20230804T201853_T10WEE -> √
 20230804T201851_20230804T202447_T10WEE -> √
 20230806T200859_20230806T201056_T10WEE -> √
 20230807T202851_20230807T203151_T10WEE -> √
 20230808T195901_20230808T195945_T10WEE -> √
 20230811T200901_20230811T200857_T10WEE -> √
 20230812T202849_20230812T202934_T10WEE -> √
 20230813T195859_20230813T195900_T10WEE -> √
 20230814T201851_20230814T202428_T10WEE -> √
 20230809T201859_20230809T201853_T10WEE -> error: Image.rename: Parameter 'input' is required.
Polygon 1:
 20230801T200901_20230801T200857_T10WEE -> √
 20230802T202849_20230802T202847_T10WEE -> √
 20230803T195859_20230803T200054_T10WEE -> √
 20230804T201851_20230804T201853_T10WEE -> √
 20230804T201851_20230804T202447_T10WEE -> √
 20230806T200859_20230806T201056_T10WEE -> √
 20230807T202851_20230807T203151_T10WEE -> √
 20230808T195901_20230808T195945_T10WEE -> √
 20230811T200901_20230811T200857_T10WEE -> √
 20230812T202849_20230812T202934_T10WEE -> √
 20230813T195859_20230813T195900_T10WEE -> √
 20230814T201851_20230814T202428_T10WEE -> √
 20230809T201859_20230809T201853_T10WEE -> error: Image.rename: Parameter 'input' is required.
Polygon 2:
 20230801T200901_20230801T200857_T10WEE -> √
 20230802T202849_20230802T202847_T10WEE -> √
 20230803T195859_20230803T200054_T10WEE -> √
 20230804T201851_20230804T201853_T10WEE -> √
 20230804T201851_20230804T202447_T10WEE -> √
 20230806T200859_20230806T201056_T10WEE -> √
 20230807T202851_20230807T203151_T10WEE -> √
 20230808T195901_20230808T195945_T10WEE -> √
 20230811T200901_20230811T200857_T10WEE -> √
 20230812T202849_20230812T202934_T10WEE -> √
 20230813T195859_20230813T195900_T10WEE -> √
 20230814T201851_20230814T202428_T10WEE -> √
 20230809T201859_20230809T201853_T10WEE -> error: Image.rename: Parameter 'input' is required.
dugalh commented 1 week ago

Thanks for raising this. The COPERNICUS/S2_CLOUD_PROBABILITY/20230809T201859_20230809T201853_T10WEE image geedim needs for cloud masking COPERNICUS/S2_SR_HARMONIZED/20230809T201859_20230809T201853_T10WEE doesn't exist. I am looking into a way of dealing with this situation.