1

I am trying to loop over a list of dates that I am pulling from a column in a feature collection which causes errors. If I define the exact same dates in a list by hand, the function seems to work.

Can anyone provide insight into why one works and why another does not?

The EE link is here, https://code.earthengine.google.com/e58b4bb03fc1060e1f359a8a28a402d6.

and the code is here,

var pts = "users/spotter/combustion_scaling/original/modis/with_date"

//get a vector of all the unique dates in pts
var all_dates = pts.distinct(["Date"]).aggregate_array("Date");
print(all_dates.type);

//----------this part does not work
var feat_iteration = ee.FeatureCollection(all_dates.map(function(date){
  print(date);
  return(date)
}));

//----this part works
// var manual_dates = ['2001-07-01', '2006-01-01']
// var feat_iteration = manual_dates.map(function(date){
//   print(date);
// });

1 Answer 1

2

You cannot use print() inside a mapping operation on a computed (server-side) list object. Instead, map to produce the result you want and then print the entire result. Or, if absolutely necessary, use .evaluate() to get the value as a client-side list and then use .map or .forEach.

3

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.