3

I have uploaded a table in GEE with height and diameter columns.Now I want to write a function that would apply an equation to each feature. I am unable to use a simple equation as I might have done in excel. The '.expression ' in GEE works only on images not on feature collection. Please suggest a simple method to do it.

Here is the link to my fusion table: https://www.google.com/fusiontables/DataSource?docid=1tuVLITArmX663I8wGZ3l6h-hAN9_q6wO_5papUwi

This is the equation I want to implement : ln(AGB)=5.349+0.96*ln(D^2H)

where D is for DBH (m) and H is for height (m)

1

1 Answer 1

5

To create a computed property for a feature collection, you can map a function over it as explained here: https://developers.google.com/earth-engine/feature_collection_mapping.

In your case, this would be the code:

/***
 * Computes ln(AGB)=5.349+0.96*ln(D^2H)
 */
function computeLnAGB(feature) {
  var d = ee.Number(feature.get('DBH (m)'));
  var h = ee.Number(feature.get('Height (m)'));

  return feature.set({ v: d.pow(h.multiply(2)).log().multiply(0.96).add(5.349) });
}

var features = ee.FeatureCollection('ft:1tuVLITArmX663I8wGZ3l6h-hAN9_q6wO_5papUwi');

// generate a new property for all features
features = features.map(computeLnAGB);

// show new property values
print(features.aggregate_array('v'));

https://code.earthengine.google.com/d10435d22e4b0d53a33439b17475ea5c

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.