1

I am reducing an image collection into a feature collection by using a function to map the reduceRegions function to each image in a collection. I'm trying to make sure the system:time_start property is carried over. My code is below

var DHW_region = DHW.map(function(image){
  return image
  .reduceRegions({
  collection:reefsEdit , 
  reducer:ee.Reducer.mean(), 
  scale: 30
 })
  .set(ee.Date(image.get('system:time_start')));
 });

 DHW_region = DHW_region.flatten();

However, it doesn't seem to work and I'm getting an error

FeatureCollection (Error)
Error in map(ID=0): Dictionary: Unrecognized arguments to Dictionary constructor.

Where am I going wrong with this? Link to my code is here

2
  • you should share the collections (DHW_region and reefsEdit) or make proxy ones so we can reproduce the error Commented Jan 28, 2021 at 11:00
  • Thanks I have added a link to my code. Line 164. Run the code and you should see the error. thanks. Commented Jan 28, 2021 at 12:23

1 Answer 1

1

The argument of .set() should be as follows (see docs):

var_args (VarArgs): Either a dictionary of properties, or a vararg sequence of properties, e.g. key1, value1, key2, value2, ..

In your code, you set an ee.Date() as argument for .set(). You should 1) make a a vararg sequence of properties or 2) make a dictionary of properties:

.set('system:time_start',image.date())

.set({'system:time_start',: image.date()})

link code

1
  • ah OK thanks, that stops the error Commented Jan 29, 2021 at 10:07

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.