Using the below function I am getting an error when I convert the GEE javascript to Python script

Viewed 28

my code looks like this.

Function:

    s2SrWithCloudMask = ee.Join.saveFirst('cloud_mask').apply({
      'primary': s2Sr,
      'secondary': s2Clouds,
      'condition': ee.Filter.equals({'leftField': 'system:index', 
      'rightField': 'system:index'})
     })

Error i got when I try to run my code as follows:

Unrecognized argument type to convert to a FeatureCollection: {'primary': <ee.imagecollection.ImageCollection object at 0x7fda2ad54610>, 'secondary': <ee.imagecollection.ImageCollection object at 0x7fda2aa00e10>, 'condition': <ee.filter.Filter object at 0x7fda2aa0bb50>}

Any suggestions would be helpful. Thanks in advance.

1 Answers

Python, unlike JavaScript, has dedicated syntax for named function arguments. The Earth Engine client follows this difference, so you need to use named argument syntax instead of dictionary syntax. This means:

  • No {}
  • Use = instead of :
  • Do not quote the parameter names
    s2SrWithCloudMask = ee.Join.saveFirst('cloud_mask').apply(
      primary=s2Sr,
      secondary=s2Clouds,
      condition=ee.Filter.equals(leftField='system:index', rightField='system:index')
    )
Related