I have uploaded 35 images (annual maximum NDVI) to GEE and put them manually (drag and drop) together to an image collection. There is no time band, but for the ee.Reducer.linearFit() function, I need to add the year of each image as a time band to each image.

I found this image.addBands(image.metadata('system:time_start') but since there is no system:time_start, this can not be used.

This is another way of doing it:

var Maxyears = ee.List.sequence(1981, 2015);
var NDVIMax35 = ee.ImageCollection.fromImages(
  ee.List.sequence(0, NDVI_Max_Stack.bandNames().length().subtract(1))
    .map(function(i) {
      return NDVI_Max_Stack.select(ee.Number(i))
        .set('year', Maxyears.get(i));

But I have the image collection already, so I need a different function than fromImages()


2 Answers 2


You can edit the metadata to specify a start time when you upload an image:

Section of upload dialog

Or you can edit it after upload, but after you open the asset info dialog, make sure to click the “Edit” toggle button to enable editing. You must do this before putting them in the collection as they are not editable within the collection.

Section of edit dialog

Then the images will have a system:time_start property as you're familiar with and you can use any of the usual techniques to turn that into a band.

If you are uploading from the command line with earthengine upload then use the --time_start option. If you are uploading using manifests use the start_time field.

If you have an existing collection that does not have standard time metadata, but has the information somewhere else such as the image's ID, then you can map over the collection to copy it into system:time_start, such as in this example where I delete the dates from a standard collection and reconstitute them:

var imageCollection = ee.ImageCollection("LANDSAT/LO08/C01/T1");

var noDates = imageCollection.map(function (image) {
  return image.set('system:time_start', null);
print(noDates.first().date().format());  // will error

var withDatesAgain = noDates.map(function (image) {
  return image.set('system:time_start', 


  • Thank you for your answer! It worked. But it is doable with a small amount of images. Worked with my 35. But it gets problematic if you want to use e.g. new data or other images collections.
    – Mathias
    Jun 24, 2020 at 12:38
  • @Mathas I have expanded my answer to cover the cases of uploading a new collection from the command line or programmatically (in which case the program can and should set the start time as it uploads) or constructing a date from other information in a collection if necessary.
    – Kevin Reid
    Jun 24, 2020 at 16:27

This is another method in the cases of uploading a new collection.

  1. You can use copyProperties method to copy 'system:time_start' when you calculate NDVI.
    var NDVI = sentinel.map(
    function(img) {
         return img.normalizedDifference(['B8','B4'])
                  .copyProperties(img, ['system:time_start']);
  1. Transform 'system:time_start' to 'year' and then add 'year' band to the image collection.
   var dataset = ee.ImageCollection('LANDSAT/LT05/C01/T1_SR')
                 .map(function(img) {
                         var date = ee.Image(img).date();
                         var Year = date.get('year');
                         var B1 = img.select(['B1']);
                         var zones = ee.Image(0).where(B1.gt(-5000), Year);
                         var zones2 = zones.mask(zones).rename('year');
                         return img.addBands(zones2)
  • I tried your second code but when I added the image collection to the map I got this error: Tile error: "Tile error: Expected a homogeneous image collection, but an image with an incompatible band was encountered. Mismatched type for band 'year': Expected type: Short<0, 1984>. Actual type: Short<0, 1985>. Image ID: LT05_026037_19850304 This band might require an explicit cast." Do you know why it doesn't work?
    – lena
    Jun 3, 2022 at 17:10

Your Answer

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

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