利用表達式計算一個數(shù)據(jù)集的增強結(jié)果
主要功能
對數(shù)據(jù)集的所有數(shù)據(jù)執(zhí)行多項式計算獲得計算結(jié)果進行展示
代碼
// Map an expression over a collection.
//
// Computes the mean NDVI and SAVI by mapping an expression over a collection
// and taking the mean. This intentionally exercises both variants of
// Image.expression.
// Filter the L7 collection to a single month.
var collection = ee.ImageCollection('LANDSAT/LE07/C01/T1_TOA')
.filterDate('2002-11-01', '2002-12-01');
// A function to compute NDVI.
var NDVI = function(image) {
return image.expression('float(b("B4") - b("B3")) / (b("B4") + b("B3"))');
};
// A function to compute Soil Adjusted Vegetation Index.
var SAVI = function(image) {
return image.expression(
'(1 + L) * float(nir - red)/ (nir + red + L)',
{
'nir': image.select('B4'),
'red': image.select('B3'),
'L': 0.2
});
};
// Shared visualization parameters.
var vis = {
min: 0,
max: 1,
palette: [
'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
'74A901', '66A000', '529400', '3E8601', '207401', '056201',
'004C00', '023B01', '012E01', '011D01', '011301'
]
};
Map.setCenter(-93.7848, 30.3252, 11);
// Map the functions over the collection, reduce to mean and display.
Map.addLayer(collection.map(NDVI).mean(), vis, 'Mean NDVI');
Map.addLayer(collection.map(SAVI).mean(), vis, 'Mean SAVI');
步驟分析
- 創(chuàng)建數(shù)據(jù)集對象箱蟆,使用名稱,日期來篩選獲得LE07特定數(shù)據(jù)
- 定義函數(shù)刮便,實現(xiàn)輸入影像數(shù)據(jù)空猜,返回NDVI計算結(jié)果
- 定義函數(shù),實現(xiàn)輸入影像數(shù)據(jù)恨旱,返回調(diào)節(jié)植被指數(shù)SAVI計算結(jié)果
- 設(shè)置顯示參數(shù)
- 設(shè)置地圖中心辈毯,縮放等級
- 添加NDVI圖層,展示結(jié)果
- 添加SAVI圖層搜贤,展示結(jié)果