I can't find out why either maxPixels and either bestEffort works to reduce and image collection like this below. I always get too many pixels.

// Load and filter the Sentinel-2 image collection.
var collection = ee.ImageCollection('COPERNICUS/S2_SR').select('B4', 'B8')
    .filterDate('2019-05-01', '2019-09-30');

var geom = ee.Geometry.Point(-122.08384, 37.42503).buffer(50000);

// Create and print the chart.
//print(ui.Chart.image.series(collection, geom, ee.Reducer.mean(), 20 ));
//print(ui.Chart.image.series(collection, geom, ee.Reducer.median(), 50 ));
//print(ui.Chart.image.series(collection, geom, ee.Reducer.min(), 50));

var mean = ee.ImageCollection('COPERNICUS/S2_SR').select('B4', 'B8')
    reducer: 'mean',
    geometry: ee.Geometry.Point([-122.27, 37.87]).buffer(1000),
    scale: 1,
    bestEffort: true,
    maxPixels: 1e9


print(ui.Chart.image.series(collection, geom, ee.Reducer.mean(), 20 ));

Do you have any ideas?

2 Answers 2


There are a couple of things why your task not completes. The task that actual fails is the presentation of the graph. The ui.Chart.series does not have the option to set a bestEffort or maxPixels, thus we first have to use reduceRegion, and then print a chart of the resulting featurecollection.

First, note that you do not filter your collection by region. As such, your are trying to print a chart of thousands of images which are not in your region of interest. Thus we first filter the collection by date and region.

// define geometry
var geom = ee.Geometry.Point(-122.08384, 37.42503).buffer(50000);
// Load and filter the Sentinel-2 image collection.
var collection = ee.ImageCollection('COPERNICUS/S2_SR').select('B4', 'B8')
    .filterDate('2019-05-01', '2019-09-30')
    // Don't forget filtering the image by region

Then note that we use the var collection in our following operations. We can get a feature for every mean B4 and B8 value by mapping over the image collection and applying reduceRegion on every image.

var meanVals = ee.FeatureCollection(collection.map(function(image){
  var mean = image.reduceRegion({ reducer: 'mean',
    geometry: geom,
    scale: 10, // native scale of the bands
    // bestEffort: true, // set bestEffort if run out of memory
    // tileScale: 4, // set higher to increase speed
    maxPixels: 1e15});
  return ee.Feature(null, {meanB4: mean.get('B4'), meanB8: mean.get('B8')
  }).set(image.toDictionary(image.propertyNames())); // copy the image properties

If we set the maxPixels high enough, we are able to print the chart. Note that you can increase the scale or tileScale and enable the bestEffort arguments to increase speed of the calculations. Make sure you read the documentation about this to understand the differences. Also, you have the possibility to export the table (to assets or drive). See the link below.

print(ui.Chart.feature.byFeature(meanVals, 'system:time_start', ['meanB4','meanB8']));

Additional note: You will see that you get multiple values per day. That is due to the data distribution of the ESA. See for example here or here to first aggregate images taken at a similar day.

link code


You have set scale to 1. That means, that Earth Engine is calculating at a scale of 1 meter per pixel.

For Sentinel Data this resolution is way too high and is also the reason for your too many pixels error. Set scale: 30 and see if it runs. If it doesn't try maxPixels: 1e11.

That should definitely work then. If it still isn't working you can export the result without loss of accuracy.

  • Thanks TomazicM for the answer! I tried all of the mentioned methods, but neither of them worked unfortunately. If I set scale to 40 instead of 20 in the last line, it works but than I loose the high-resolution which I would like to keep. But with 155.178.686 points the graph does not show up. Even if I set the Maxpixel to 255.178.686 it does not work. What am I doing wrong?
    – Tamás
    Commented Feb 24, 2020 at 13:35
  • @Tamás You're not doing anything wrong. In the browser Earth Engine simply isn't going to calculate anything with that many pixels. The solution for your problem would be to calculate your data and then export it. When you're exporting the data Earth Engine is much more lenient with how many pixels you can reduce.
    – JonasV
    Commented Feb 24, 2020 at 14:05

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.