2

I have FeatureCollection in GEE , so for each feature there is data in the properties about total number of pixels, means and more data.

enter image description here

I would like to add new column with computation based on this data in the dictionary, for example, new column (or key) that will be the result of computation of bt0204/count, or any other computation.

How can I access this key-value data in order to run computations? How can I run computation over values in dictionaries?

My end goal: to be able to calculate the percentage of different pixels values , for example to run bt0204/count*100, and have the result as new key (column).

Edit: I have tried to use this method just to get the number:

var num=dictionary.get('bt0204');

and then print it, but I get null. maybebe because there are many features? I don't know

4

The objects that you get on your computer (via the Earth Engine Code Editor or otherwise) are always represented as dictionaries (or JSON objects, if you like that term) but within Earth Engine they are different types of objects and to operate on them you need to use the operations with that specific type.

I see from your picture you have a FeatureCollection with some features in it, and the features have properties. To process an entire FeatureCollection, you use map. To get a property from a feature, you use get (or one of its variations that specifies the type). To store the result, you use set to define a new property on each feature.

So, this might do what you want:

var collectionWithCount = myFeatureCollection.map(function (feature) {
  return feature.set('percentage',
     feature.getNumber('bt0204').divide(feature.getNumber('count')).multiply(100));
});
print(collectionWithCount);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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