I am trying to rank the temperature anomalies in a time series. Basically, I would like to have a raster showing the position of year X (eg 2020) in a time series (eg first hottest (value=1), second hottest (value=2), 15th hottest,...). Let me try to explain better with an example. For a pixel I have the following anomalies for the last 5 years. Then the anomalies have been ranked (2019 is the hottest 'largest anomaly', 2020 is the second hottest,...)
I would like to produce a layer for the year 2020 where my pixel has the value 2 (rank) I have been able to produce a raster showing the hottest year in a TS but do not know how to produce the annual ranked value
This is how far I managed to get - it's just getting the year of the max anomaly:
var startYear = 1981
var endYear = 2020
// Dummy collection of anomalies to have shortest possible code to reproduce my question
var anom = ee.ImageCollection(
ee.List.sequence(startYear, endYear)
.map(function (year) {
year = ee.Number(year)
return ee.Image([
ee.Image.random(year).multiply(10000).int16().rename('anom'),
ee.Image(year).int16().rename('year')
]).set('year', year)
})
)
print(anom, 'anomalies')
var ROI = Map.getBounds(true)
var YYmax = anom.qualityMosaic('anom')
print(YYmax, 'YYmax')
Map.addLayer(YYmax.clip(ROI), {
bands: 'year',
min: startYear,
max: endYear,
palette: ["LemonChiffon", "Gold", "Orange", "Red", "Maroon"]
}, 'YYmax')
https://code.earthengine.google.com/dd0447086b40fd85453c963b7ff9e50d
Here is my complete code https://code.earthengine.google.com/ea25c30f8724851e6ab0e946d8ed9e41
Can anybody help?
{}
button that enables you to format any highlighted code nicely. Please check out our short tour for more about how the site works. Thanks.