12

Is there a way to add a property to a feature in the GEE. I know that you can edit existing properties with set(), but haven't found a way to add a property.

1 Answer 1

16

Yes, you can use the feature.set()option which Feature Overview covers with these examples:

// Make a feature and set some properties.
var feature = ee.Feature(ee.Geometry.Point([-122.22599, 37.17605]))
.set('genus', 'Sequoia').set('species', 'sempervirens');

// Get a property from the feature.
var species = feature.get('species');
print(species);

// Set a new property.
feature = feature.set('presence', 1);

// Overwrite the old properties with a new dictionary.
var newDict = {genus: 'Brachyramphus', species: 'marmoratus'};
var feature = feature.set(newDict);

// Check the result.
print(feature);
2
  • Oh well, guess i skipped that part :D Thanks for the quick answer!
    – Kai
    Commented Nov 5, 2018 at 15:17
  • Sure thing, I'm glad I was able to answer your question.
    – whyzar
    Commented Nov 5, 2018 at 15:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.