2

The way that I export the time series of a point of an image collection as .csv file is to click the top right button of the chart displayed in the console of earth engine, which generated from the time series. The following code shows how I extract the time series of a point by its coordinate and generate a chart to display in the console. Then I click the top right button of the chart to export as .csv file.

However, I have 30 points of interest, in my way, I have to input the coordinate of each point manually and run the code every time, and then click the top right button of the chart of each point to export .csv file again and again until I finish the export of time series for all points. So is there any convenient way to accomplish this? Maybe I should input the coordinates of points in a loop, and export the .csv file also in a loop, but I don't know how to do it.

// the coordinate of a point, I enter it manually every time.       
    var lng = -92.56894444;
    var lat = 37.21702778;
    var r = ee.Geometry.Point(lng, lat); // r is the point of interest
    // Load Landsat 7 imagery and filter it
     var collection = ee.ImageCollection('LANDSAT/LE07/C01/T1_SR')
        .filterDate('2011-01-01','2011-12-31') // the period of interest.
        .filterBounds(r);
Map.setCenter(lng, lat, 13);

//plot a chart of the imagecollection B4 band; then I click the top right button of the chart in the console to export the time series as a .csv file.
print(ui.Chart.image.series(collection.select('B4'), r, ee.Reducer.mean(), 30))
3

If you just want an CSV for every point, similar to the one you get from the chart button, use this:

// the coordinate of a point, I enter it manually every time.       
    var lng = -92.56894444;
    var lat = 37.21702778;
    var r = ee.Geometry.Point(lng, lat); // r is the point of interest
    // Load Landsat 7 imagery and filter it
     var collection = ee.ImageCollection('LANDSAT/LE07/C01/T1_SR')
        .filterDate('2011-01-01','2011-12-31'); // the period of interest.


// function to exprt a CSV file
function exportCSV(collection, point){

  // filter the images
  collection = collection.filterBounds(point);

  // get the values of band 4
  var feats = collection.map(function(image){
    return ee.Feature(null, image.select('B4').reduceRegion(ee.Reducer.mean(), point, 30))
                .set('system:time_start', image.get('system:time_start'));
  });

  print('test export', feats);

  // export a CSV file
  Export.table.toDrive({
    collection: feats, 
    description: 'YOURDISCRIPTION', 
    folder: 'YOURFOLDER', 
    fileFormat: 'CSV', 
    selectors: ['system:time_start', 'B4']
  });
}

// apply function and export just one point
exportCSV(collection, r)

In this link, I also gave you some suggestions to export multiple points at once.

If you want a more complex, but in the end easier output within one CSV file, see this examples by Nick Clinton: youtube, slides, code

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.