0

I am trying to convert a FeatureCollection (a bit heavy one though) to an Imagecollection. It seems that the job has been done successfully, however, I can't take any further steps with the Imagecollection such as clipping or reducing, and I cannot address the issue, Ang thoughts on this? Here is the link to the code:

https://code.earthengine.google.com/31de43e96b218cac08248e9177800d7e

1 Answer 1

4

This is due to the client/server split of Earth Engine.

The Earth Engine servers know that if you map() a feature collection and each result feature is an image, then the result collection can be an image collection. But the Earth Engine client — the JavaScript (or Python) functions you actually call to define your computation — don't look at the map() and conclude "this always returns an ee.Image". So, as far as the client knows, you're working on a FeatureCollection, not an ImageCollection, and can't use any methods of ImageCollection.

The solution is to write a cast, to inform the client that the result will definitely be an ImageCollection:

//                  add this to your script
//                    ↓        ↓       ↓
var imageCollection = ee.ImageCollection(featureCollection.map(function (feature) {
  return ee.Image.constant(feature.get('myProperty')).rename('myBand');
}));
0

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.