In Google Earth Engine, I am getting an object obj
from an aggregate_histogram
call, and print(obj)
shows the following:
{
"115.0": 1,
"137.0": 1,
"35.0": 137,
"42.0": 164
}
I would like to extract the key for which the value is largest, so "42.0" (which should please most everyone as the correct answer to any big question).
How can I proceed?
I know how to do it in pure JavaScript, but here it doesn't look like it works:
print(Object.keys(obj)) // yields "[]"
EDIT: adding more info after the first answer by Kosh.
var obj = loc.aggregate_histogram('relativeOrbitNumber_start')
var o = {
"115.0": 1,
"137.0": 1,
"35.0": 137,
"42.0": 164
};
print(o)
print(obj)
print(Object.keys(o))
print(Object.keys(obj))
This yields the following: