I would like to calculate the area of all non-zero pixels on multiple bands of an image. My idea was to use
var areaImage = image.multiply(ee.Image.pixelArea());
To do that I will need an image where pixel values equal 1, so I was trying to use
However, since I am using a multi-band image, I receive a flattened image with only 1 band.
How could I assign all non-zero pixels a value of 1 across all bands without losing the bands? Or is there a smarter way to go about it?
Here is the code I tried:
//----load MCD64A1 Version 6 Burned Area and create a multi-band image var datasetAll = ee.ImageCollection(MODISglobal500) .filter(ee.Filter.date('2000-01-01', '2019-12-31')) .filterBounds(border); var DSall1B = datasetAll.select('BurnDate') var DSallImage = DSall1B.toBands() //----convert pixels to value = 1 var ImageValue1= DSallImage.reduce(ee.Reducer.allNonZero()) //----create an image with pixels value = area var ImageValueArea = ImageValue1.multiply(ee.Image.pixelArea())