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)
print(chart)
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')
Best Answer
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:
Where "system:index" is the point ID number.