5

I want to get the properties of a feature. How can I do that? In the example below we can get one of the properties out like so feature.get('species'). How can we get all of them at once? This is a failure feature.get('properties')

It works for geometry like feature.geometry() but not for properties.

// 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.
print(feature.get('species'));

print(feature.get('properties'));

1 Answer 1

7
//dictionary of property names and values
print(feature.toDictionary())

//or list of either property names or values
print(feature.toDictionary().keys())
print(feature.toDictionary().values())


1
  • 1
    print(feature.toDictionary(feature.propertyNames())) if you also want the system properties
    – Kuik
    Commented Feb 19, 2020 at 0:41

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.