0

I have a list of FeatureCollection of points in Google Earth Engine that I would like to merge into a single FeatureCollection, the documentation on merge says that one should make a collection of collections then use .flatten.

Note: If many collections need to be merged, consider placing them all in a collection and using FeatureCollection.flatten() instead. Repeated use of FeatureCollection.merge() will result in increasingly long element IDs and reduced performance.

But the API doesn't seem to provide a mechanism to turn a list of FeatureCollections into a single FeatureCollection. How can I do this?

1 Answer 1

1

Simply call ee.FeatureCollection() with the list to convert it to a FeatureCollection. This works for any list of features or feature-like values (features, collections, images).

var listOfFC = ee.List([
  ee.FeatureCollection([ee.Feature(null, {'x': 1})]),
  ee.FeatureCollection([ee.Feature(null, {'x': 2})]),
  ee.FeatureCollection([ee.Feature(null, {'x': 3})]),
  ee.FeatureCollection([ee.Feature(null, {'x': 4})]),
]);

print(ee.FeatureCollection(listOfFC).flatten());

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.