I want to select a region on a map and get the time series for NDVI based on Landsat 8 imagery. If possible, it would be better if I can get the image row and path through matching the Landsat tiles by my area of interest.

However, I need to select Landsat 8 C2L2 image, filter that for specific time and region with least cloud coverage then get image acquistion time to plot NDVI as a time series.

l8 = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2");

var L8=l8.filterDate('2021-01-01', '2021-11-11')
         .filter(ee.Filter.eq('WRS_PATH', 178))
         .filter(ee.Filter.eq('WRS_ROW', 34))
//         .copyProperties(l8, ['system:time_start']);

When the copyProperties line is uncommented, most of the sequentional commands fail to run

print('L8 Mosaic',L8.mosaic())

I can sort images by time here:

var L8Sorted=L8.sort('system:time_start', false)//.limit(10)
print('L8Sorted Time',L8Sorted)

function applyScaleFactors(image) {
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0);
  return image.addBands(opticalBands, null, true)
              .addBands(thermalBands, null, true);

L8 = L8.map(applyScaleFactors);

I want to apply NDVI computation on each image on different dates for my area of interest to produce a time series. I am unsure if mosaic is right for this purpose.

var NDVI=L8.mosaic().normalizedDifference(['SR_B5','SR_B4'])

Above mentioned NDVI returns just one image.

And I can't get their time to use in ui.chart function.

How can I achieve my aim?


1 Answer 1


here is the last complete code after a while

// first select parsels from TKGM
var P1 = ee.FeatureCollection('users/Solmaz/TKGM/Agriculture1');
var P2 = ee.FeatureCollection('users/Solmaz/TKGM/Agriculture2');
var P3 = ee.FeatureCollection('users/Solmaz/TKGM/Agriculture3');
var P4 = ee.FeatureCollection('users/Solmaz/TKGM/Agriculture4');
var P5 = ee.FeatureCollection('users/Solmaz/TKGM/Agriculture5');
var P6 = ee.FeatureCollection('users/Solmaz/TKGM/Forest1');
var P7 = ee.FeatureCollection('users/Solmaz/TKGM/Forest2');
var P8 = ee.FeatureCollection('users/Solmaz/TKGM/Mine_Manual');

var p1 = P1.geometry().coordinates()
var p2 = P2.geometry().coordinates()
var p3 = P3.geometry().coordinates()
var p4 = P4.geometry().coordinates()
var p5 = P5.geometry().coordinates()
var p6 = P6.geometry().coordinates()
var p7 = P7.geometry().coordinates()
var p8 = P8.geometry().coordinates()

var PP1 = ee.FeatureCollection([
    .set('label', 'Agriculture1')
    .set('value', '0')
var PP2 = ee.FeatureCollection([
    .set('label', 'Agriculture2')
    .set('value', '1')
var PP3 = ee.FeatureCollection([
    .set('label', 'Agriculture3')
    .set('value', '2')
var PP4 = ee.FeatureCollection([
    .set('label', 'Agriculture4')
    .set('value', '3')
var PP5 = ee.FeatureCollection([
    .set('label', 'Agriculture5')
    .set('value', '4')
var PP6 = ee.FeatureCollection([
    .set('label', 'Forest1')
    .set('value', '5')
var PP7 = ee.FeatureCollection([
    .set('label', 'Forest2')
    .set('value', '6')
var PP8 = ee.FeatureCollection([
    .set('label', 'Mine')
    .set('value', '7')

var Polygons = PP1.merge(PP2).merge(PP3).merge(PP4).merge(PP5).merge(PP6).merge(PP7).merge(PP8);

// Load MODIS vegetation indices data and subset a decade of images.
var vegIndices = ee.ImageCollection('MODIS/006/MOD13Q1')
                     .filter(ee.Filter.date('2020-01-01', '2021-11-18'))
                     .select(['NDVI', 'EVI']);

// Define the chart and print it to the console.
var chart =
          imageCollection: vegIndices,
          band: 'NDVI',
          regions: Polygons,
          reducer: ee.Reducer.mean(),
          scale: 250,
          seriesProperty: 'label',
          xProperty: 'system:time_start'
          title: 'Average NDVI Value by Date',
          hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
          vAxis: {
            title: 'NDVI (x1e4)',
            titleTextStyle: {italic: false, bold: true}
          lineWidth: 4,
          colors: ['ffffe5', 'f7fcb9','d9f0a3','addd8e','a1d99b','006837','00441b','980043'],

Map.addLayer(Polygons,{},'Sample Regions')

Map.addLayer(ee.Image().paint(Polygons, 0, 4), {palette: ['#dd1c77','#dd1c77']}, 'TKGM Parsels'); 
//Map.addLayer(ee.Image().paint(P2, 0, 4), {palette: ['#dd1c77','#dd1c77']}, 'Forest'); 

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.