0

I am new in Google Earth Engine, I am trying to plot ndvi timeseries from a single polygon of shapefile, but when I run the code I get "Error generating chart: Collection query aborted after accumulating over 5000 elements".

var broad_leaved= ee.FeatureCollection('users/spatola/MCD45A1_broad_leaved_311/MCD45A1_2004_clc311');
var modis = ee.ImageCollection('MODIS/006/MOD13Q1');
var modisNDVI = modis.filterBounds(broad_leaved)
                    .filterDate('2002-01-01', '2009-12-31')
                    .select('NDVI');
                    print(modisNDVI);
var timeseries = ui.Chart.image.seriesByRegion(
  modisNDVI, broad_leaved , ee.Reducer.mean(), 'NDVI', 250)
  .setOptions({
    title : 'vegetation series',
    xAxis : {title : 'YEAR'},
    yAxis : {title : 'NDVI'}
    });
  print(timeseries);
2
  • There is a user limit of 5000 elements to plot in a single graph. You should either use .limit(5000) to plot a subset or export the result to e.g. Excel Export.table.toDrive() and plot it there.
    – Kuik
    Commented Oct 10, 2019 at 8:32
  • Thank you for your answer, but i already tried and it didn't work Commented Oct 10, 2019 at 11:22

1 Answer 1

2

I believe the issue is in your feature collection. I can't access it as you don't have it shared, so can't investigate what is going on there.

But I have tested the script with a random geometry placed on the map, and had no issues.NDVI of somewhere Central USA

Check that your feature collection doesn't have too many features to it.

==================================

EDIT

Thanks for including the link. The problem lies with the fact that you have 1918 features in your collection, and 184 images in that collection.

Multiply those 2 numbers together, and you get more than 5000 elements.

In any case I'm not sure how much information you would extract from a graph that had 1918 NDVI series on it.

Here is the modified code so you can see the print in the console.

var table = ee.FeatureCollection("users/spatola/MCD45A1_broad_leaved_311/MCD45A1_2004_clc311");

print("Original",table);

var subset = table.limit(2);
print("Subset",subset);

var broad_leaved= subset //ee.FeatureCollection('users/spatola/MCD45A1_broad_leaved_311/MCD45A1_2004_clc311');
var modis = ee.ImageCollection('MODIS/006/MOD13Q1');
var modisNDVI = modis.filterBounds(broad_leaved)
                    .filterDate('2002-01-01', '2009-12-31')
                    .select('NDVI');
                    print(modisNDVI);
var timeseries = ui.Chart.image.seriesByRegion(
  modisNDVI, broad_leaved , ee.Reducer.mean(), 'NDVI', 250)
  .setOptions({
    title : 'vegetation series',
    xAxis : {title : 'YEAR'},
    yAxis : {title : 'NDVI'}
    });
  print(timeseries);

This code gives the following image. enter image description here

Perhaps what you meant to do is have a chart for each polygon? That would give you 1918 charts, and I'm unsure how to build it so that you could print it to the console.

3

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.