I am trying to weghted overlay in Google Earth Engine I want to overlay PDSI, SPI and SMI applying weights for each parameter.
This is how I am going to overlay them:
var overlay = spi.add(smi.add(pdsi))
How do I apply weighted overlay?
I am trying to weghted overlay in Google Earth Engine I want to overlay PDSI, SPI and SMI applying weights for each parameter.
This is how I am going to overlay them:
var overlay = spi.add(smi.add(pdsi))
How do I apply weighted overlay?
You can use GEE's ee.Image.expression()
function for more complex mathematical operations like both addition and multiplication as in your case (more info e.g. here and here). As it works on an ee.Image
, you need to combine your layers into one at first using ee.Image.addBands()
.
Example code (factors need to be adjsted accordingly):
var image = spi.addBands(smi).addBands(pdsi)
var overlay = image.expression(
'2 * spi + 5 * smi + 1.5 * pdsi', {
'SPI': image.select('spi'),
'SMI': image.select('smi'),
'PDSI': image.select('pdsi')
});