I'm starting to use the GEE Python API and I'm struggling with the translation of some instructions from JavaScript to Python.

I'm using the following code in JS:

var all_alerts  = ee.ImageCollection('projects/glad/alert/UpdResult')
var country     = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017').filter(ee.Filter.eq('country_co', 'CG'));
var alerts_2020 = all_alerts.select('conf20').mosaic().clip(country);  

  scale: 30,
  maxPixels: 1e10

and it work like a charm.
Naive I'd like to make the same with the python API:

def get_alerts(country_code, year):
    country = ee.FeatureCollection('USDOS/LSIB_SIMPLE/2017').filter(ee.Filter.eq('country_co', country_code))
    all_alerts  = ee.ImageCollection('projects/glad/alert/UpdResult')
    alerts = all_alerts.select(year).mosaic().clip(country);
    file_name = 'alerts_' + country_code + '_' + year
    task_config = {
        'scale': 30,
        'maxPixels': 1e10
    task = ee.batch.Export.image.toDrive(**task_config)

country_code = 'CG'
year= 'conf20'
get_alerts(country_code, year)

The task start on my GEE taskboard but rise the following error :

Error: GeometryConstructors.LineString, argument 'coordinates': Invalid type. Expected type: List. Actual type: FeatureCollection.

which I don't understand because it the exact same call I was making (or so I think).

1 Answer 1


I think adding .geometry() after country will work:

task_config = {
    'scale': 30,
    'maxPixels': 1e10

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.