I've wrote a code for modis ndvi timeseries(code below). But it returns error in chart creating (ui.Chart.image.seriesByRegion) : Error generating chart: Invalid argument specified for ee.Number(): system:time_start

var regions = ee.FeatureCollection([
  ee.Feature(    // forest.
    ee.Geometry.Rectangle(geometry), {label: 'forest'}),
    ee.Feature(    // crop.
    ee.Geometry.Rectangle(geometry2), {label: 'crop'})
  ]) ;

var modis = ee.ImageCollection("MODIS/006/MOD13Q1")

var mod13 = modis.map(function(img){
  var id = img.id();
  img = img.select("NDVI").rename(id);
  return img.multiply(0.0001)


var timeseries = ui.Chart.image.seriesByRegion(
    title : 'vegetation series',
    xAxis : {title : 'time'},
    yAxis : {title : 'NDVI'},
    lineWidth : 1,
    pointSize : 2,
    series : {
      0 : {color : 'red'},
      1 : {color : 'green'}


1 Answer 1


Well clearly the charting function is not happy with the input arguments. While creating mod13, you renamed all the NDVI bands to corresponding dates (not sure why you would do that, because chart uses dates from the system:time). Images within the collection mod13 doesn't contain a unique band name.

Now when you call ui.Chart.image.seriesByRegion, it is expecting the following order of arguments: imageCollection, regions, reducer, band, scale, xProperty, seriesProperty. At the place of band it finds 250 which is the scale. So you have two options:

  1. Use ui.Chart.image.seriesByRegion(mod13, regions, ee.Reducer.mean()) with first three arguments, assuming you don't want to change the scale
  2. Do not rename the NDVI band in mod13 and use ui.Chart.image.seriesByRegion(mod13, regions, ee.Reducer.mean(), 'NDVI', 250, 'system:time_start', 'label')

See https://code.earthengine.google.com/9f86ca8486070c7f440c3fa1ea02dd4b for complete example.

PS. Your code is not exactly reproducible. geometry and geometry2 are not defined.

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.