I am trying to map a function over an image collection in python. I am able to run same process in JavaScript, but in Python I am having issues.
Here is the code in JavaScript, which returns a JSON full of values:
var smap = ee.ImageCollection('NASA_USDA/HSL/SMAP_soil_moisture').filterDate('2019-04-25', '2019-05-17')
var geom = ee.Geometry.Point([-94.440367, 42.1068856])
var res = smap.map(function(image) {
var reduced = image.reduceRegion({geometry: geom,
reducer: ee.Reducer.mean(),
crs: 'EPSG:4326',
scale: 30})
return image.set('value', reduced);
});
var vals = res.aggregate_array('value');
print(vals);
However, when I run this in python, I get an empty list:
smap = ee.ImageCollection('NASA_USDA/HSL/SMAP_soil_moisture').filterDate('2019-04-25', '2019-05-17')
geom = ee.Geometry.Point([-94.440367, 42.1068856])
def eeAlgo(image):
reduced = image.reduceRegion(geometry=geom, reducer=ee.Reducer.mean(), crs='EPSG:4326', scale=30)
image.set('value', reduced)
return image
vals = smap.map(algorithm=eeAlgo)
vals.aggregate_array('value').getInfo()
> []
Is there some difference between running this in Python that I am missing? Or is this a bug that I should file at https://github.com/google/earthengine-api? I am using Python 2.7.