GEE影像集合ImageCollection中的統計計算


GEE影像集合ImageCollection中的統計計算


a. reduce(reducer,parallelScale)

  1. reducer:計算方法,如均值、最大值等
  2. parallelScale:縮放比例,為一個后台優化參數,如果計算內存溢出可以設置2、4等

影像集合中的reduce主要是所有影像提取對應波段計算生成單景影像。此外,需要注意Earth Engine中的所有操作底層本質都是在操作像素,這里計算結果為逐像素的結果。

案例:計算ImageCollection內的NDVI均值影像

var roi = /* color: #98ff00 */ee.Geometry.Polygon(  
        [[[114.62959747314449, 33.357067677774594],  
          [114.63097076416011, 33.32896028884253],  
          [114.68315582275386, 33.33125510961763],  
          [114.68178253173824, 33.359361757948754]]]);  
Map.centerObject(roi, 7);  
Map.setOptions("SATELLITE");  //set SATELLITE basemap

var l8Col = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")  //Note:TOA!!!
              .filterBounds(roi)  
              .filterDate("2018-1-1", "2019-1-1")  
              .map(ee.Algorithms.Landsat.simpleCloudScore)//add cloud property
              .map(function(image) {  //select cloud <= 20
                return image.updateMask(image.select("cloud").lte(20));  
              })  
              .map(function(image) {  // add NDVI band
                var ndvi = image.normalizedDifference(["B5", "B4"]).rename("NDVI");  
                return image.addBands(ndvi);  
              })  
              .select("NDVI");  
print(l8Col);
var img = l8Col.reduce(ee.Reducer.mean(),4);   // or var img = l8Col.mean();  
print(img);
Map.addLayer(roi, {color: "red"}, "roi"); 

由此代碼也可以延伸開來,例如:

  • 計算ImageCollection中的雲量少於xx%的影像數量結果進行導出
  • 計算ImageCollection中最大值或者最小值NDVI指數啥的作為分類的物候特征指標
    注意:這里的.filterBounds(roi)出來的只是與roi相交的行列號影像

b. reduceColumns(reducer,selectors,weightSelectors)

  1. reducer:計算方法,如均值、最大值等
  2. selectors:屬性列表
  3. weightSelectors:屬性列表對應的權重信息,通常默認

該方法用於統計屬性的基本信息,例如統計影像結合所有的索引信息,並且返回列表,
主要使用Reducer中的.toList()方法,將影像集合中每一個元素的屬性信息聚合在一起以列表形式返回。

案例:提取影像集合中所有影像ID的列表

var roi = /* color: #98ff00 */ee.Geometry.Polygon(  
        [[[114.62959747314449, 33.357067677774594],  
          [114.63097076416011, 33.32896028884253],  
          [114.68315582275386, 33.33125510961763],  
          [114.68178253173824, 33.359361757948754]]]);  
Map.centerObject(roi, 7);  
var l8Col = ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA")  
              .filterBounds(roi)  
              .filterDate("2018-1-1", "2019-1-1")  
              .map(ee.Algorithms.Landsat.simpleCloudScore)  
              .map(function(image) {  
                return image.updateMask(image.select("cloud").lte(20));  
              });  
print(l8Col);
// 需要將對象類型中的list取出
var indexs = l8Col.reduceColumns(ee.Reducer.toList(), ["system:index"])  
                  .get("list");  
print("indexs", indexs);  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM