1

Link to GEE

function BAI(Im){
var pcr = 0.1
var pir = Im.select('B3')
var pcnir = 0.06
var pinir = Im.select('B4')
var one = 1
var bai = one.divide(pcr.subtract(pir).pow(2).add(pcnir.subtract(pinir).pow(2)))
return bai
}
var BAIColle = LSatTMCf.map(BAI)

When running this code, the Error "pcr.subtract is not a function". I guess the issue is with pcr beeing a number and pir being a Pixel Value from an Image

1

You need to create an image with a constant value for each of your parameters. Furthermore, you forgot to filter your image-collection by the bounds of your aoi (https://code.earthengine.google.com/c0ff852ccc0e1b9811314f2bc2743cd6):

//Filter ImageCollections
var LSatTMCf = LSatTMC.filterDate('2008-01-01','2008-12-31').filterBounds(aoi);

//Center Map
Map.centerObject(aoi, 10);

function BAI(Im){
  var pcr = ee.Image(0.1)
  var pir = Im.select('B3')
  var pcnir = ee.Image(0.06)
  var pinir = Im.select('B4')
  var one = ee.Image(1)
  var bai = one.divide(pcr.subtract(pir).pow(2).add(pcnir.subtract(pinir).pow(2)))
  return bai
}
var BAIColle = LSatTMCf.map(BAI)

print(BAIColle)

Map.addLayer(BAIColle.first())

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.