I am getting an error trying to subtract one property from another in GEE:

Tile error: Error in map(ID=null):
Number.subtract: Parameter 'left' is required.

here is my code:

var urb=ee.FeatureCollection('users/data');


// This function computes the feature's UHI
var getUHI = function(feature) {
//  print(ee.Number.parse(feature.get('LST_urb_day_CT')));
  var urban = ee.Number(feature.get('LST_urb_day_CT'));
  var UHI = urban.subtract(ee.Number(feature.getNumber('LST_rur_day')));
  return feature.set({UHI: UHI});

// Map the area getting function over the FeatureCollection.
var UHIAdded = urb.map(getUHI);

1 Answer 1


In order to use a method of an Earth Engine value/object, the type of the value has to be known when your code is executed, which happens before the request is even sent to Earth Engine's servers.

You know the property's value is a number. The Earth Engine server will find out it a number. But the Earth Engine client library that's processing feature.get(...) doesn't know that, so you have to tell it that the value will be a number:

var urban = ee.Number(feature.get('LST_urb_day_CT'));

In most cases, this is automatic because the type is implied by the method/algorithm you used — for example, urb.map knows that feature is a feature because urb is a FeatureCollection. But the values of properties are always of unknown type since they could be almost anything, so you usually need a cast along with .get().

  • Thanks a lot! I followed your commet but it is now giving me this error... somehow the number didn't match with the FeatureCollection? census track: Tile error: Error in map(ID=null): Number.subtract: Parameter 'left' is required.
    – Gaole Dai
    Nov 24, 2019 at 21:48
  • @GaoleDai That means the property is missing on that feature.
    – Kevin Reid
    Nov 24, 2019 at 23:11
  • I tried to drop Nulls by replacing it with var UHIAdded = urb.map(getUHI, true); but it still says the same error?
    – Gaole Dai
    Nov 25, 2019 at 18:10
  • @GaoleDai dropNulls doesn't have any effect there because it applies to the result of the map(), by which time the error has already occurred. Try using .filter(ee.Filter.notNull(['LST_urb_day_CT'])) before the .map().
    – Kevin Reid
    Nov 25, 2019 at 18:32

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.