So, I got the code to work for T1_TOA band, but then when I switched it over to T1_SR band it gave me this error: User memory limit exceeded. So, I poked around the forum and found the code to limit my date frames, but I still get the error. Not quite sure what I'm missing.
// Import the Landsat 8 SR image collecton.
Map.addLayer(study_area, {color: 'Black'}, "study_area");
function maskL8sr(image) { // Bits 3 and 5 are cloud shadow and cloud, respectively. var cloudShadowBitMask = (1 << 3); var cloudsBitMask = (1 << 5); // Get the pixel QA band. var qa = image.select('pixel_qa'); // Both flags should be set to zero, indicating clear conditions. var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0) .and(qa.bitwiseAnd(cloudsBitMask).eq(0)); return image.updateMask(mask); }
var dataset = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR') .filterBounds(study_area) .map(maskL8sr) .select('B5' , 'B4'); print(dataset);
var startDate = ee.Date('2013-05-01'); // set analysis start time var endDate = ee.Date('2013-9-30'); // set analysis end time
// 'Reduce' stack of images by using the median value for each pixel and clip to study area var output_bands = dataset.reduce(ee.Reducer.median()).clip(study_area); print(output_bands) // var index = output_bands.normalizedDifference(['B5_median', 'B4_median']); // NDVI calculated using NIR and red bands print(index); // DISPLAY metadata
// DISPLAY output band Map.addLayer(index, {}, 'NDVI');
print(ui.Chart.image.series({ imageCollection: index, region: study_area, reducer: ee.Reducer.median(), scale: 30 }).setOptions({title: 'Cloud-masked NDVI over time'}));