光谱分离是在地球引擎中实现的image.unmix()
方法。以下是将 Landsat 5 与预先确定的城市、植被和水端元混合的示例:
unmix(endmembers, sumToOne, nonNegative)
Unmix each pixel with the given endmembers, by computing the pseudo-inverse and multiplying it through each pixel. Returns an image of doubles with the same number of bands as endmembers.
通过计算伪逆并将其乘以每个像素,将每个像素与给定的端元分开。返回具有与末端成员相同数量的带图像。
Arguments:
this:image (Image):
The input image.
endmembers (List):
The endmembers to unmix with.
sumToOne (Boolean, default: false):
Constrain the outputs to sum to one.
nonNegative (Boolean, default: false):
Constrain the outputs to be non-negative.
Returns: Image
直接上代码:
// 加载影像并且选择波段,之后选择位置显示中心和加载影像
var bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7'];
var image = ee.Image('LANDSAT/LT05/C01/T1/LT05_044034_20080214')
.select(bands);
Map.setCenter(-122.1899, 37.5010, 10);
Map.addLayer(image, {bands: ['B4', 'B3', 'B2'], min: 0, max: 128}, 'image');
// 定义光谱端元,这个参数具体要看更加详细的光谱内容
var urban = [88, 42, 48, 38, 86, 115, 59];
var veg = [50, 21, 20, 35, 50, 110, 23];
var water = [51, 20, 14, 9, 7, 116, 4];
// 取消混合,这样就进行了分解
var fractions = image.unmix([urban, veg, water]);
Map.addLayer(fractions, {}, 'unmixed');