I am new to the Google Earth Engine Python API, and I am trying to create functions that when mapped over a collection will print some metadata (e.g. time stamp, band names) but I always get the same error:

EEException: ValueNode is empty

Here is the code:

import ee

# Getting the Sentinel 1 image over the study site
collection = ee.ImageCollection('COPERNICUS/S1_GRD').filterBounds(ee.Geometry.Point(121.1737372,24)).filterDate('2019-01-01','2019-01-30')
collectionList = collection.toList(collection.size())
sentinel1 = ee.Image(collectionList.get(1)).select('VH')

##Function to print the dates of a collection
def printDate(image):
  date = ee.Date(image.get('system:time_start'))
  print('Time stamp:'+str(date.format('Y-M-d').getInfo()))


def collectionBands(img):
  bands = img.bandNames()
  print('band names:'+str(bands.getInfo()))


1 Answer 1


From the JavaScript docs (it's essentially identical to the Python docs, but easier to get to, as it's there in the code editor):

ImageCollection.map(algorithm, dropNulls)


algorithm (Function): The operation to map over the images or features of the collection. A JavaScript function that receives an image or features and returns one. The function is called only once and the result is captured as a description, so it cannot perform imperative operations or rely on external state.


This is a bit cryptical, but it implies that it doesn't make sense to print inside the function you pass to .map(). The function is called only once, no matter how many images you have in the collection. In addition to this, you'll get an error if you call .getInfo() inside that function, and the function must return an ee.Feature or ee.Image.

Here's how you could get the dates and band names printed:

collection = ee.ImageCollection('COPERNICUS/S1_GRD') \
    .filterBounds(ee.Geometry.Point(121.1737372,24)) \

dates = ee.List(collection \
    .aggregate_array('system:time_start')) \
    .map(lambda time_start: 
    ) \

band_names = collection \
    .map(lambda image: 
         image.set('bandNames', image.bandNames())
   ) \
    .aggregate_array('bandNames') \

for date in dates:

for band_name in band_names:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.