I am currently working with a raster file which shows peatlands in the Congo Basin and the ESA/CCI/FireCCI/5_1 image collection (images for each month between 2001-2019). My end goal is to create visual thumbnails of seasonal (blocks of 3 months) burn area over the peatlands and charts, as well as derive inter-annual trends between the same three months across all years.
Current challenge: I have tried to use the multiply operator between the fire image collection and the peatlands image and it doesn't work between an image and an image collection. I am trying to create a new fire image collection over the peatlands only.
A pixel value of 1 indicates peat in the peatlands image and I have reclassified the fire image collection so that 1 indicates land cover that has been burnt.
Annotated code developed so far below:
//Add layers
GretaMap_extent = ee.FeatureCollection("users/n/Vector_peats");//vector of extent of peatland map
PeatlandMap_Greta = ee.Image("users/n/peat_nopeat"); //peatland map
// Visualize FireCCI51 from 2001-2019
var dataset = ee.ImageCollection('ESA/CCI/FireCCI/5_1')
.filterDate('2001-01-01', '2019-12-31')
.filterBounds(GretaMap_extent)
.map(function(image){return image.clip(GretaMap_extent)}) ;
print(dataset);
var burnedArea = dataset.select('LandCover');//all burned pixels are classified according to LandCover
//Palette for Burn Area
var baVis = {
min: 0,
max: 180,
palette: [
'ffff64', 'aaf0f0', 'dcf064', 'c8c864', '006400', '00a000', '003c00', '285000', '788200',
'8ca000', 'be9600', '966400', 'ffb432', 'ffdcd2', 'ffebaf', '009678', '00dc82'
]
};
//Palette for peatland map
var peatlandsvis = {
min: 0,
max: 1,
palette: ['white', 'fuchsia']
};
//only keep pixels with a value of 1 (peat)
var onlyPeat = PeatlandMap_Greta.updateMask(
PeatlandMap_Greta.neq(0) // Only keep pixels where values don't equal zero
);
//visualize peat and burn pixels together
Map.setCenter(30, 0, 6.1);
Map.addLayer(burnedArea, baVis, 'Burned Area');
Map.addLayer(onlyPeat, peatlandsvis, 'Peatlands Map');
//Reclassify the LandCover because I'm only interested in the burn pixels, not their land cover
var reclassify = function(image) {
return image.remap(
[0, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 170, 180],//land cover values
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],//recode all to 1
null,//mask out all other values, which shouldn't exist anyways
'LandCover');//band name
};
var new_ds = burnedArea.map(reclassify);// new variable which applies reclassification to burnedArea
print(new_ds);
Map.addLayer(new_ds);//I think this worked. Not sure?
//Now: how to only show fire on peatlands?