1

I am getting an error trying to parse a number to float in GEE, here is my code:

var getUHI = function(feature) {
  var urban = ee.Number(feature.get('LST_urb_day_CT'));
  var UHIday = ee.Number.toFloat(urban.subtract(ee.Number(feature.getNumber('LST_rur_day'))));
  return feature.set({UHIday: UHIday});
};

var UHIAdded = urb.map(getUHI);

currently in the featureCollection UHIAdded, 'LST_urb_day_CT' and 'LST_rur_day' are both type float, but after I parse them to numbers to calculate UHIday, UHIday becomes Number. I want to parse UHIday back to float but it tells me toFloat is not a function?

2
  • Does var UHIday = urban.subtract(ee.Number(feature.getNumber('LST_rur_day'))).float() work? Commented Nov 25, 2019 at 19:37
  • it still says that UHIday is a Number not a float...
    – Gaole Dai
    Commented Nov 25, 2019 at 20:48

1 Answer 1

1

You can get float from a number like so:

var UHIday = ee.Number(urban.subtract(ee.Number(feature.getNumber('LST_rur_day')))).float()
2
  • it still says that UHIday is a Number not a float...
    – Gaole Dai
    Commented Nov 25, 2019 at 20:43
  • I believe javascript sees all numbers as only numbers. if there is decimals then it is considered a float, otherwise it's a integer... But it will remain a Number.
    – B-C B.
    Commented Nov 25, 2019 at 21:29

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.