0

I want to calculate seasonal variations of LST over some years

what I have so far is monthly average but can't make seasons out of those months !!

here is my code

var LandsatLST = require('users/sofiaermida/landsat_smw_lst:modules/Landsat_LST.js')
var geometry = ee.Geometry.Rectangle( 32.96780026,28.39841527,32.97560417,28.40330991);
var satellite = 'L7';
var date_start = '2000-01-01';
var date_end = '2021-12-30';
var use_ndvi = true;
var LandsatColl = LandsatLST.collection(satellite, date_start, date_end, geometry, use_ndvi)
var LandsatColl = LandsatColl.select("LST")
//#convert to Celsius
var LandsatColl = LandsatColl.map(function(img) {
  return img
    .subtract(273.15)
    .copyProperties(img, ['system:time_start']);
});

var years = ee.List.sequence(2000, 2021);
var months = ee.List.sequence(1, 12);

var yrMo = ee.ImageCollection.fromImages(
  years.map(function (y) {
   return months.map(function (m) {
            return LandsatColl
              .filter(ee.Filter.calendarRange(y, y, 'year'))
              .filter(ee.Filter.calendarRange(m, m, 'month'))
              .mean()
              .set('Month', m)
              .set('year',y)
               .copyProperties(LandsatColl, ['system:time_start']);
        });
    }).flatten());

I want to filter the image collection by seasonal average, I tried :

  var seasons = ee.List([[1,3], [4,6], [7,9],[10,12]])
  var createSeasonComposites = function(months) {
  var startMonth = ee.List(months).get(0)
  var endMonth = ee.List(months).get(1)
  var monthFilter = ee.Filter.calendarRange(startMonth, endMonth, 'month')
  var seasonFiltered = yrMo.filter(monthFilter)
  var composite = seasonFiltered.mean()
  return composite
}
var compositeList = seasons.map(createSeasonComposites)

print(compositeList,"seasons")

but the ee.Filter.calendarRange() doesn't work in my case due to the absence of timestamps which I tried to add but failed ?!

Any help how to make the seasonal averages ?

1
  • I ended up doing monthly time series and downloaded it to R for seasonal variations ! Feb 1, 2022 at 23:15

1 Answer 1

0

You can't copyProperties like this when you work on an image collection inside your yrMo mapped function. The approach seems to be working, here is a suggestion to get the timestamp property working working:

 var timestamp = ee.Image(subset.first()).get('system:time_start')

But you end up with another problem, namely seasons/year combinations without images. So in the link below I show you the examples it works for to copy the timestamp property:

https://code.earthengine.google.com/eadf4867626f2625d48f4283722140e6

2
  • Thank you, exactly I need seasons/year which is my question. Jan 31, 2022 at 18:05
  • Thank you, exactly I need seasons/year which is my question. Jan 31, 2022 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.