1

I want to apply random forest classification on landsat C2L2 data.

I found code for Landsat Top of Atmosphere (TOA) collection but i think its better to use C2L2 colection (i will be so glad if any one can reveal for me for what TOA dataset is more used in applications. as i think C2L2 imagary is better for landcover classifications as better spectra is provided)

for this the image is defined as follow to train the model by random forest:

var composite = ee.Algorithms.Landsat.simpleComposite({
  collection: landsatCollection,
  asFloat: true
});

and landsatcollection is defined as:

var landsatCollection = ee.ImageCollection('LANDSAT/LC08/C01/T1')
    .filterDate('2021-01-01', '2021-11-25');

now I want to replace this image set with C2L2 and developed the code as here

function scaleFactor(image) {

  // Apply the scaling factors to the appropriate bands.
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0);

  // Replace the original bands with the scaled ones and apply the masks.
  return image.addBands(opticalBands, null, true)
      .addBands(thermalBands, null, true)
}
var collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
                     .filterBounds(roi)
                     .filterDate('2021-01-01', '2021-11-15')
                     .map(scaleFactor)
                     .select(['SR_B1', 'SR_B2', 'SR_B3', 'SR_B4', 'SR_B5', 'SR_B6', 'SR_B7','ST_B10'])
                     .sort('CLOUD_COVER').first();

var landsat = ee.Image(collection).float();


var composite = ee.Algorithms.Landsat.simpleComposite({
  collection: landsat,
  asFloat: true
});

but when i run the full code for newly defined landsat dataset the error is presented as folows:

composite
Image (Error)
Landsat.simpleComposite: ImageCollection band names do not match a Landsat instrument.

can any one guide me for that? and here is the full code:

https://code.earthengine.google.com/?scriptPath=users%2FSolmaz%2FBurdur_Sentinel_CloudFree%3ALandsat%20Random%20Forest%20Final%20C2L2

0

Your Answer

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