I need an automated process for downloading a timeseries across multiple bands for a large number of pixels in the Google Earth Engine.

For one pixel, I have this piece of code:

var input_point = [4.666901, 50.649889]
var disp = .0005
Map.setCenter(input_point[0], input_point[1], 15)

var ee_input_point = ee.Geometry.Point(input_point)
Map.addLayer(ee_input_point,{}, 'SamplePoint')

var start = '2021-03-01'
var end = '2021-10-31'

var s2_sr = ee.ImageCollection('COPERNICUS/S2_SR').filterDate(start, end)
s2_sr = s2_sr.filter(ee.Filter.bounds(ee_input_point)).select(['B1', 'B2', 'B3'])
var s2_sr_p = s2_sr.map(function(img){return img.clip(ee_input_point)})

var chart = ui.Chart.image.series(s2_sr_p, ee_input_point)

The chart shows precisely what I need, and I can manually download the data as CSV. However, I would like to convert this code to Python and have it process a large number (1e3) of points. I can't figure out how to generate and download the chart data as a CSV (to drive). In Python, ui is not available.

Update This produces a CSV which I can process further. If someone has a cleaner solution or one, which can handle multiple points without having to queue thousands of jobs in the queue, I am still very interested.

var stacked = s2_sr_p.toBands()
var means = stacked.reduceRegions(ee_input_point, ee.Reducer.mean().forEachBand(stacked), 10)
Export.table.toDrive(means, 'test1', 'px', 'test', 'CSV')

1 Answer 1


You can use an ee.FeatureCollection of points. You don't need to add the points individually as I have done in the example, you can upload a shapefile of multiple points and it will be converted to a FeatureCollection automatically.

This script should be translatable to Python:

var points = ee.FeatureCollection([
                   ee.Geometry.Point([4.666501, 50.649889]), 
                   ee.Geometry.Point([4.666901, 50.649289]), 
                   ee.Geometry.Point([4.666921, 50.649369])


// you can use `centerObject` to avoid having to get the coordinates for `setCenter`

var start = '2021-03-01'
var end = '2021-10-31'

var s2_sr = ee.ImageCollection('COPERNICUS/S2_SR').filterDate(start, end)
                    // `filterBounds(...)` is shorthand for `filter(ee.Filter.bounds(...)`
                    .filterBounds(points).select(['B1', 'B2', 'B3'])

// no real need to clip because `reduceRegions` gets individual pixels from the point locations
// var s2_sr_p = s2_sr.map(function(img){return img.clip(points)})

var stacked = s2_sr.toBands();
var means = stacked.reduceRegions(points, ee.Reducer.mean().forEachBand(stacked), 10);
Export.table.toDrive(means, 'test', 'px', 'test', 'CSV');

enter image description here

Where "system:index" is the point ID number.

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.