I created a feature collection where features are grid cells, columns are monthly images and the values represent pixel area. I would like to find the mean for each feature over all columns. I tried to use reduceColumns
but I get the mean for each column rather than for each feature.
script:
//----load image collection, filter, and create an image with multiple bands
var datasetAll = ee.ImageCollection(MODIS/006/MCD64A1)
.filter(ee.Filter.date('2000-01-01', '2019-12-31'))
.filterBounds(border);
var DSall1B = datasetAll.select('BurnDate')
var DSallImage = DSall1B.toBands()
//----filtering grid to the area
var grid1degreeF = grid1degree.filterBounds(border);
//----creating a layer where pixels value are the pixel area in m^2
var DSallValue1 = DSallImage.where(DSallImage, 1)
var DSallAPP1 = DSallValue1.multiply(ee.Image.pixelArea())
//----summing area in each grid cell over all bands
var DSallAPP1d1 = DSallAPP1.reduceRegions({
reducer: ee.Reducer.sum(),
collection: grid1degreeF,
scale: 500,
});
Here are my assets:
border- https://code.earthengine.google.com/?asset=users/stavo/amazon_border_harvard
grid- https://code.earthengine.google.com/?asset=users/stavo/Vectorgrid_1degree
This is where I got so far. I end up with the feature collection I described before and now I wish to get the mean for each cell over all columns (dates).
This is the method I tried:
var properties = DSallAPP1.bandNames();
var means = DSallAPP1d1
.filter(ee.Filter.notNull(properties))
.reduceColumns({
reducer: ee.Reducer.mean().repeat(229),
selectors: properties
});
After calculating the means I was planning to use reduceToImage so I can end up with an image of the area means over time divided into grid cells. I assume that my method is not the most efficient one. Please advise how to calculate the means or how to approach the issue differently.