eMapR / LT-GEE

Google Earth Engine implementation of the LandTrendr spectral-temporal segmentation algorithm. For documentation see:
https://emapr.github.io/LT-GEE
Apache License 2.0
195 stars 65 forks source link

buildSRcollection does not work for southern hemisphere #26

Open S-AQ opened 3 years ago

S-AQ commented 3 years ago

In update 14.11 on 2018-06-13, you wrote that you improved the buildSRcollection function to account for the medoid image of the growing season of the southern hemisphere. The theory was that as long as you take the startDay later in the year than the endDay, you would result in a medoid image collection consisting of acquisition dates somewhere in January for example.

I ran the following code snippet that was published along with the update, but it did not result in acquisition dates in the southern summer.

// load the LandTrendr.js module
var ltgee = require('users/emaprlab/public:Modules/LandTrendr.js');

// define parameters
var startYear = 1985;
var endYear = 2017;
var startDay = '12-20';
var endDay = '02-20';
var aoi = ee.Geometry.Point(-122.8848, 43.7929);

// center and zoom the display in case outputs are to be mapped 
Map.centerObject(aoi,10);
Map.addLayer(aoi);

// apply LandTrendr.js functions
var annualSRcollection = ltgee.buildSRcollection(startYear, endYear, startDay, endDay, aoi);

// add property 'acquisition_date' to each image with the date converted to UNIX style. 
var annualSRcollection = annualSRcollection.map(function(im){
  var newdate = ee.Date(im.get('system:time_start')).format("yyyy-MM-dd");
  return im.set({'acquisition_date': newdate});
});
print(annualSRcollection);

But the code returns an image collection where all images are taken around August 31st image

Why does it do that?

Could it have anything to do with the hardcoded date of August 1st in lines 217 and 205?

line 205: .set('system:time_start', (new Date(year,8,1)).valueOf()); // add the year to each medoid image - the data is hard-coded Aug 1st

line 217: imgs = imgs.concat(tmp.set('system:time_start', (new Date(i,8,1)).valueOf())); // concatenate the annual image medoid to the collection (img) and set the date of the image - hard coded to the year that is being worked on for Aug 1st

jdbcode commented 3 years ago

The date for the annual medoid composites is hard coded. See line https://github.com/eMapR/LT-GEE/blob/8e38e0f5bb8813b42521fd9f8633eba5514b5674/LandTrendr.js#L217

The comment says August first, but the month parameters for the Date function is 0-based month index, not month number. It's a little strange that the formatted acquisition_date is August 31st, I'd expect it to be September 1st, issue is likely due to time zones.

A better solution here would be to use the median date of the images in the composite and also maybe add a property to the annual composites listing the dates of all of the images used in a given composite.

I'll keep this issue open and implement a change for better date assignment. Thanks for bring this to our attention!