3

I'd like to turn Google Earth Engine geometries to feature collection, however receive error message like:

Collection: Geometries cannot have their properties modified or be placed into collections.

How should I modify the code? My code is following:

var glc = ee.FeatureCollection('users/wangq/test_slope')
var geometries = glc.geometry().geometries()
print(geometries)

var shape = ee.FeatureCollection(geometries)
print(shape)

1 Answer 1

4

As per the documentation, a feature collection is a collection of features, and not a collection of geometries.

If you would like to combine geometries into a feature collection, first convert each geometry into a feature using

var features = geometries.map(function(g){
  return ee.Feature(ee.Geometry(g));
});

Then, combine the features into a feature collection using

var shape = ee.FeatureCollection(features)

Link to complete code.

1
  • Thanks for your answer. Pretty useful!
    – wangq
    Commented May 9, 2021 at 6:53

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.