0

I am getting Error generating chart: No features contain non-null values of "system:time_start" building a monthly landsat LST:

var geometry = 
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[-75.35023860347604, 41.76108398613208],
          [-75.35023860347604, 39.69663659517741],
          [-71.98842219722604, 39.69663659517741],
          [-71.98842219722604, 41.76108398613208]]], null, false),
    imageCollection = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2"),
    imageCollection2 = ee.ImageCollection("LANDSAT/LC09/C02/T1_L2");


Map.centerObject(geometry);

var time_start= '2023' , time_end='2024'

var landsat8 = imageCollection
.filterDate(time_start,time_end)
.filterBounds(geometry)
.filter(ee.Filter.lt('CLOUD_COVER',45));

//print(landsat8)

var landsat9 = imageCollection2
.filterDate(time_start,time_end)
.filterBounds(geometry)
.filter(ee.Filter.lt('CLOUD_COVER',45));

//print(landsat9)

var landsat_collection= landsat8.merge(landsat9)
.sort('system:time_start');

//print(landsat_collection)

function temporal_collection(collection, start, count, interval, unit){
  var seq = ee.List.sequence(0,ee.Number(count).subtract(1));
  var origin_date= ee.Date(start);
  return ee.ImageCollection(seq.map(function(i){
    var start_date = origin_date.advance(ee.Number(interval).multiply(i),unit);
    var end_date = origin_date.advance(ee.Number(interval).multiply(ee.Number(i).add(1)),unit);
    return collection.filterDate(start_date,end_date).median()
    .set('system:time_start', start_date.millis())
    .set('system:time_start', end_date.millis())
  }))
}

var landsat_monthly = temporal_collection(landsat_collection, time_start,12,1,'month')
//print(landsat_monthly)

var temp = landsat_monthly.select('ST_B10').map(function(img){
  var kel = img.multiply(0.00341802).add(149);
  var cel = kel.subtract(273.15);
  return cel
  .copyProperties(img, ['system: time_start', 'system: time_end'])
});
//print(temp)

print(ui.Chart.image.series(temp, geometry, ee.Reducer.mean(), 100,'system:time_start'));

// print(
//   ui.Chart.image.series({
//     imageCollection: temp, 
//     region: geometry, 
//     reducer: ee.Reducer.mean(),
//     scale: 100, 
//     xProperty: 'system:time_start'
//   }))

Map.addLayer(temp.toBands().clip(geometry),[],'temp',false)

I have tried several ways using print ui chart time series but the error is still the same.

What is wrong here?

1 Answer 1

0

You've got a typo in your code that's affecting the .copyProperties function. It should be written as 'system:time_start' and 'system:time_end'.

Instead, you've written 'system: time_start' and 'system: time_end'.

The spaces inside the property names in your original code are causing issues with identifying the correct properties to copy. Removing these spaces should fix the issue.

2
  • Thank you very much for your feedback. It works. Commented Apr 23 at 2:15
  • Super, happy to hear it worked. Could you accept the answer?
    – M. Nicolas
    Commented Apr 24 at 23:13

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.