Search code examples
pythongoogle-earth-engine

Google Earth Engine Python API, converting ee.list to Python list


I am using Google Earth Engine's Python API which provides result objects such as ee.number, ee.list, ee.image. I do not know which detail I am missing but the following code:

import ee
ee.Initialize()

collection = ee.ImageCollection('MODIS/MCD43A4_NDVI')
print collection.toList(10)

returns:

ee.List({
  "type": "Invocation", 
    "arguments": {
    "count": 10, 
    "collection": {
      "type": "Invocation", 
      "arguments": {
        "id": "MODIS/MCD43A4_NDVI"
      }, 
     "functionName": "ImageCollection.load"
    }
  }, 
  "functionName": "Collection.toList"
})

How can I get an actual Python list? Using any method displayed by

print dir(collection.toList(10)) 

just adds to this JSON output.


Solution

  • The following code returns a list of dictionaries containing the desired information:

    import ee
    ee.Initialize()
    
    collection = ee.ImageCollection('MODIS/MCD43A4_NDVI')
    list = collection.toList(10)
    print list.getInfo()