Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 233
Falk Schuetzenmeister Avatar asked Aug 10 '26 19:08

Falk Schuetzenmeister


1 Answers

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()
like image 87
Falk Schuetzenmeister Avatar answered Aug 13 '26 15:08

Falk Schuetzenmeister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!