您需要提供有关如何格式化表格的更多信息。以下是导出单个频段以帮助您入门的两种方法的示例:
var roi = /* color: #d63000 */ee.Geometry.Polygon(
[[[-122.27577209472656, 37.891247253777074],
[-122.27577209472656, 37.86875557241152],
[-122.24040985107422, 37.86875557241152],
[-122.24040985107422, 37.891247253777074]]], null, false);
// Load imagery.
var l8 = ee.ImageCollection('LANDSAT/LC8_SR')
.filterBounds(roi)
.filterDate('2016-01-01', '2016-12-31')
.map(function(image) {
var qa = image.select('cfmask');
var mask = qa.neq(2).and(qa.neq(4));
return image.updateMask(mask).divide(10000);
});
print('Size of Landsat collection', l8.size()); // 21
// Load an Earth Engine table.
var blocks = ee.FeatureCollection('TIGER/2010/Blocks');
var subset = blocks.filterBounds(roi);
print('Size of Census blocks subset', subset.size()); // 409
Map.centerObject(roi, 13);
Map.addLayer(blocks, {color: 'gray'}, 'blocks');
Map.addLayer(subset, {}, 'subset');
// Collect block, image, value triplets.
var triplets = l8.map(function(image) {
return image.select('B1').reduceRegions({
collection: subset.select(['blockid10']),
reducer: ee.Reducer.mean(),
scale: 30
}).filter(ee.Filter.neq('mean', null))
.map(function(f) {
return f.set('imageId', image.id());
});
}).flatten();
print(triplets.first());
// Format a table of triplets into a 2D table of rowId x colId.
var format = function(table, rowId, colId) {
// Get a FeatureCollection with unique row IDs.
var rows = table.distinct(rowId);
// Join the table to the unique IDs to get a collection in which
// each feature stores a list of all features having a common row ID.
var joined = ee.Join.saveAll('matches').apply({
primary: rows,
secondary: table,
condition: ee.Filter.equals({
leftField: rowId,
rightField: rowId
})
});
return joined.map(function(row) {
// Get the list of all features with a unique row ID.
var values = ee.List(row.get('matches'))
// Map a function over the list of rows to return a list of
// column ID and value.
.map(function(feature) {
feature = ee.Feature(feature);
return [feature.get(colId), feature.get('mean')];
});
// Return the row with its ID property and properties for
// all matching columns IDs storing the output of the reducer.
// The Dictionary constructor is using a list of key, value pairs.
return row.select([rowId]).set(ee.Dictionary(values.flatten()));
});
};
var link = '78503bfa1fb76b3a9fa06b515d1e2488';
var table1 = format(triplets, 'imageId', 'blockid10');
var desc1 = 'table1_demo_' + link;
Export.table.toDrive({
collection: table1,
description: desc1,
fileNamePrefix: desc1,
fileFormat: 'CSV'
});
var table2 = format(triplets, 'blockid10', 'imageId');
var desc2 = 'table2_demo_' + link;
Export.table.toDrive({
collection: table2,
description: desc2,
fileNamePrefix: desc2,
fileFormat: 'CSV'
});
该示例来自此演示文稿,链接自此页面。