1

我正在尝试制作一些与大河流相交的 Landsat 图像。代码的输出是 ImageID。但是,当我运行代码时,大约需要 5 分钟并显示“服务当前不可用”或“超出用户内存限制”。我猜太多的图像被选择和排序。请帮忙。任何建议将不胜感激。

https://code.earthengine.google.com/1167e0c6656b0e99a345d15643a671b7

var table2 = ee.FeatureCollection("users/bo_wang1/Yukon_River");

//1. Display the shapefile into the interactive map
//Display the view to the center of the screen and scale the view
Map.centerObject(table2,10);
//Define styling and determine the color of the shapefile 
var styling = {color: 'red', fillColor: '00000000'};
Map.addLayer(table.style(styling));

//2. Loading L8 image collection (TOA reflectance)
var l8_collection= ee.ImageCollection('LANDSAT/LC08/C01/T1_SR');

//3. Filter by time window
var x1= l8_collection.filterBounds(table2)
                  .filterDate('2019-05-01', '2019-09-30')
                  .sort('CLOUD_COVER');
print ('L8 2019 image collection:',x1);
print('# images', x1.size()); 

// extract the different rows and paths
var distinctRows = x1.distinct(['WRS_ROW']).aggregate_array('WRS_ROW');
var distinctPaths = x1.distinct(['WRS_PATH']).aggregate_array('WRS_PATH');
print(distinctRows, distinctPaths)

//Extract least cloudy L8 scene in each tile
var imagePerPath = distinctPaths.map(function(path){
  var imagePerRow = distinctRows.map(function(row){
    var images = x1.filter(ee.Filter.and(ee.Filter.eq('WRS_ROW', row), ee.Filter.eq('WRS_PATH', path)));
    return images.sort('CLOUD_COVER').first();
  });
  return imagePerRow;
});
var leastCloud = ee.ImageCollection.fromImages(imagePerPath.flatten());


// print and add the geometries of the images to the map
Map.addLayer(ee.FeatureCollection(leastCloud.map(function(image){return image.geometry()})))

print('leastCloud',leastCloud);

//Get the number of images
var count = leastCloud.size();
print('Count:', count);
//Get and print property and ImageID
print(leastCloud.first().propertyNames());
var imageID = leastCloud.aggregate_array('LANDSAT_ID');
print(imageID);

//Export Landsat_ID to CSV
Export.table.toDrive({
  collection: leastCloud,
  description: 'Get_ImageID',
  folder: 'Shapefile from GEE',
  fileFormat: 'CSV',
  selectors: ['LANDSAT_ID'],
});
4

0 回答 0