When reducing an image to number on it's geographical coordinates, the code does return a number, which is what should happen.

var accum = ETo.reduce(ee.Reducer.sum());
var accumNum = accum.reduceRegion(ee.Reducer.sum(),geom,30);
accumNum = accumNum.getNumber('Potential_Evaporation_Rate_surface_6_Hour_Average_sum');
print('accum:', accumNum);

Resulting in the following print:

enter image description here

However, when I try to perform any other basic calculations such as an addition, it prints a weird string of code which doesn't contain the number at all.

print('accum:', 5 + accumNum);

Resulting print from previous operation: enter image description here

This only concatinates the 5 to the string of code description returned by the operation.

The problem also happens when I try to set a label to the value of accumNum. However, in this case I can't display the number at all even without performing any calculations.

The only thing I need is to get the actual value from the reduced region. Does anyone have a suggestion for this?


Your example is asking for a client-side operation (+) with inputs that are a client side object (5) and a server-side object (accumNum). Because of this mix, the result concatenates the client side object and the definition of server-side object (i.e. the part starting with ee.Number)

Instead, you can specify that the computation is done server-side by using ee.Image.add(). For example:

print('accum:', ee.Image(5).add(accumNum));

For more information, see the Client vs. Server section of the Earth Engine docs.

| improve this answer | |
  • Great, I will use the server sive operations to perform this calculations. For the second issue, do you know by any chance how I may be able to print the resulting value of accumNum into a panel? Thank you in advance! – Dante Jun 5 '19 at 21:12
  • Okay, I found out in the doc you provided I could use .getInfo() to retrieve data from the object in server. Thank you! – Dante Jun 5 '19 at 21:24

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.