3

I defined (by drawing) a significant number of polygons and need to export the time series of the average values inside each one. Following this example, that allows to display charts for each region, how can I export the data to a .csv? Ideally I will have in the first row the names of the regions.

// Define a FeatureCollection: regions of the American West.
var regions = ee.FeatureCollection([
  ee.Feature(    // San Francisco.
    ee.Geometry.Rectangle(-122.45, 37.74, -122.4, 37.8), {label: 'City'}),
  ee.Feature(  // Tahoe National Forest.
    ee.Geometry.Rectangle(-121, 39.4, -120.8, 39.8), {label: 'Forest'}),
  ee.Feature(  // Black Rock Desert.
    ee.Geometry.Rectangle(-119.15, 40.8, -119, 41), {label: 'Desert'})
]);

// Load Landsat 8 brightness temperature data for 1 year.
var temps2013 = ee.ImageCollection('LANDSAT/LC8_L1T_32DAY_TOA')
    .filterDate('2012-12-25', '2013-12-25')
    .select('B11');

// Create a time series chart.
var tempTimeSeries = ui.Chart.image.seriesByRegion(
    temps2013, regions, ee.Reducer.mean(), 'B11', 200, 'system:time_start', 'label')
        .setChartType('ScatterChart')
        .setOptions({
          title: 'Temperature over time in regions of the American West',
          vAxis: {title: 'Temperature (Kelvin)'},
          lineWidth: 1,
          pointSize: 4,
          series: {
            0: {color: 'FF0000'}, // urban
            1: {color: '00FF00'}, // forest
            2: {color: '0000FF'}  // desert
}});

// Display.
print(tempTimeSeries);

2 Answers 2

1

After printing the chart to the console tab:

  1. In the console tab, click on the "enlarge icon" to display the chart in a full window.
  2. In the full window, click on "Download CSV"

The first row of the resulting CSV file includes the names of the regions.

system:time_start,City,Forest,Desert
"Apr 7, 2013",297.119,273.622,286.196
"May 9, 2013",300.654,299.472,275.405
"Jun 10, 2013",287.004,300.091,320.261
"Jul 12, 2013",286.198,298.332,315.787
"Aug 13, 2013",307.255,295.935,311.532
"Sep 14, 2013",291.677,276.471,294.359
"Oct 16, 2013",285.385,283.333,279.032
"Nov 17, 2013",282.925,273.038,264.722
"Dec 19, 2013",286.648,277.89,256.074
0
0

Instead of cart use ToDrive for exporting as CSV

Export.table.toDrive({
  collection: table1, 
  description: 'this file is time series', 
  fileNamePrefix: 'this is discription',
  fileFormat: 'CSV'
});
1

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.