LT-GEE icon indicating copy to clipboard operation
LT-GEE copied to clipboard

Fix deprecated landsat collection

Open robitalec opened this issue 3 years ago • 4 comments

Hey, I was just working with the LT-GEE API and I noticed the Landsat collection being used is deprecated. I don't have a deep understanding of all the inner workings of the API - so please let me know if it isn't possible or a good idea to switch to the new collection.

The API gives a warning, pointing here:

  • https://developers.google.com/earth-engine/guides/landsat#landsat-collection-structure

and other mentions of this collection being deprecated:

  • https://developers.google.com/earth-engine/datasets/catalog/landsat
  • https://www.usgs.gov/landsat-missions/landsat-collection-1

and from the user group here (Jan 3 2022): image

As far as I can tell, L7, L8 Collection 2 have been fully ingested in Earth Engine. Not sure about L5.

Here's a script I used to quickly compare the two collections: https://code.earthengine.google.com/31b105327aa3e1a9f0dce85f9bad7bb6

From my understanding of the LT-GEE API, we'd need to apply the scaling factors given in the example script "Examples/Datasets/LANDSAT_LC08_C02_T1_L2" https://code.earthengine.google.com/638c03d87892e6ab853cd855fab44923

I'm not sure how this interacts with the Roy et al. harmonization though. So it's definitely not a one single line of code change, but I thought I'd open this to put it out there.

Thank you!

robitalec avatar Feb 11 '22 23:02 robitalec

Hi Alec, thanks for bringing this up!

I've been updating some other scripts and wanted to share a nice function for scaling and masking L8 SR C2. It would have to be modified slightly to work generically for L5, L7, L8.

function prepSrL8(image) {
  // Develop masks for unwanted pixels (fill, cloud, cloud shadow).
  var qaMask = image.select('QA_PIXEL').bitwiseAnd(parseInt('11111', 2)).eq(0);
  var saturationMask = image.select('QA_RADSAT').eq(0);

  // Apply the scaling factors to the appropriate bands.
  var getFactorImg = function(factorNames) {
    var factorList = image.toDictionary().select(factorNames).values();
    return ee.Image.constant(factorList);
  };
  var scaleImg = getFactorImg([
    'REFLECTANCE_MULT_BAND_.|TEMPERATURE_MULT_BAND_ST_B10']);
  var offsetImg = getFactorImg([
    'REFLECTANCE_ADD_BAND_.|TEMPERATURE_ADD_BAND_ST_B10']);
  var scaled = image.select('SR_B.|ST_B10').multiply(scaleImg).add(offsetImg);

  // Replace original bands with scaled bands and apply masks.
  return image.addBands(scaled, null, true)
    .updateMask(qaMask).updateMask(saturationMask);
}

I don't know what to do about the Roy correction. I think some tests need to be done to see the effect. I believe the coefficients were produced from pre-collection data. I assume that there have been improvements and steps toward aligning the data in C1 and further in C2. Anecdotally, I have seen the correction make harmonization worse, so I'm a little hesitant to continue using them without knowing more.

jdbcode avatar Feb 12 '22 00:02 jdbcode

@jdbcode Will the C1 collection stop working in the near future? I will also need to update the Landsat timelapse functions in geemap to use C2.

giswqs avatar Feb 12 '22 00:02 giswqs

@giswqs C1 will most likely be available through 2022. As soon as we know more definitively, we'll get notices out about the cutoff date.

jdbcode avatar Feb 12 '22 01:02 jdbcode

Thanks Justin! That's good to know. And thank you for the prep L8 function. I'll take a look around and see if there's any newer references for harmonization of the new collection. And let us know if you come across anything.

robitalec avatar Feb 14 '22 19:02 robitalec

The module was updated in March 2022 to use Landsat Collection 2. See https://code.earthengine.google.com/?scriptPath=users%2Femaprlab%2Fpublic%3AModules%2FLandTrendr.js to verify.

jdbcode avatar Sep 08 '22 21:09 jdbcode

Great, thank you!

robitalec avatar Sep 09 '22 17:09 robitalec