I am trying to classify land use in earth engine with L7 imagery, however a chunk of the region of interest is being left out as seen in the image.
The code can be found here:
//Set map centre
Map.setCenter(160.0348, -9.4573, 12)
//Import Landsat 7 imagery
var selection = L7.filterBounds(roi)
.filterDate("1999-01-01", "2001-01-01")
.filterMetadata("CLOUD_COVER", "less_than", 15)
.mean()
.clip(roi);
// Map.addLayer(selection);
// This example demonstrates the use of the Landsat 4, 5, 7 Collection 2,
// Level 2 QA_PIXEL band (CFMask) to mask unwanted pixels.
function maskL457sr(image) {
// Bit 0 - Fill
// Bit 1 - Dilated Cloud
// Bit 2 - Unused
// Bit 3 - Cloud
// Bit 4 - 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 opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
var thermalBand = image.select('ST_B6').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(thermalBand, null, true)
.updateMask(qaMask)
.updateMask(saturationMask);
}
// Map the function over one year of data.
var collection = ee.ImageCollection("LANDSAT/LE07/C02/T1_L2")
.filterDate('1999-01-01', '2004-01-01')
.map(maskL457sr);
var composite = collection.median().clip(roi);
// Display the results.
Map.setCenter(160.0348, -9.4573, 12);
Map.addLayer(composite, {bands: ['SR_B3', 'SR_B2', 'SR_B1'], min: 0, max: 0.3}, 'masked');
var training_points = Water.merge(BuiltUp_Urban).merge(ShrubGrass_Vegetation).merge(Dense_Vegetation).merge(Bare);
print(training_points,'training points');
var training_data = composite.sampleRegions({
collection:training_points,
properties: ['LC'],
scale: 30})
print(training_data,'training data');
var classifier = ee.Classifier.smileCart()
var classifier = classifier.train({features: training_data,
classProperty: "LC",
inputProperties: ["SR_B1","SR_B2","SR_B3","SR_B4","SR_B5","ST_B6","SR_B7"]});
var classified_image = composite.classify(classifier);
Map.addLayer(classified_image, {min: 0, max: 4},
'classified image');
and includes all the training data for the classifier. I'm not sure whether this is an issue with the L7 gaps or something unrelated.