ee.Image.constant(value)
Generates an image containing a constant value everywhere.
代码语言:javascript复制生成一个在任何地方都包含一个常量值的图像
Arguments:
value (Object):
The value of the pixels in the constant image. Must be a number or an Array or a list of numbers or Arrays.
代码语言:javascript复制恒定图像中像素的值。必须是数字或数组或数字列表或数组
Returns: Image
方法2:
ee.Dictionary.values(keys)
Returns the values of a dictionary as a list. If no keys are specified, all values are returned in the natural ordering of the dictionary's keys.
代码语言:javascript复制以列表形式返回字典的值。如果未指定键,则所有值都以字典键的自然顺序返回。主要是你影像当中的波段你是否乱序,如果没有乱序的化就按照默认就欧克,在下面的例子中我是将所有的影像波段都以列表的形式传送个一个变量。
Arguments:
this:dictionary (Dictionary)
keys (List, default: null)
Returns: List
方法3:
subtract(image2)栅格减法
Subtracts the second value from the first for each matched pair of bands in image1 and image2. If either image1 or image2 has only 1 band, then it is used against all the bands in the other image. If the images have the same number of bands, but not the same names, they're used pairwise in the natural order. The output bands are named for the longer of the two inputs, or if they're equal in length, in image1's order. The type of the output pixels is the union of the input types.
代码语言:javascript复制对于 image1 和 image2 中的每对匹配的波段,从第一个值中减去第二个值。如果 image1 或 image2 只有 1 个波段,则将其用于另一个图像中的所有波段。如果图像具有相同数量的波段,但名称不同,则它们按自然顺序成对使用。输出波段以两个输入中较长的命名,或者如果它们的长度相等,则按 image1 的顺序命名。输出像素的类型是输入类型的并集。
Arguments:
this:image1 (Image):
The image from which the left operand bands are taken.
image2 (Image):
The image from which the right operand bands are taken.
Returns: Image
最后看代码:
代码语言:javascript复制var image = ee.Image('LANDSAT/LC8_L1T/LC80440342014077LGN00')
.select(['B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11']);
// Mean center the data to enable a faster covariance reducer 平均中心数据以启用更快的协方差减少器
// and an SD stretch of the principal components.和主成分的 SD 拉伸。
//计算均值,这是为了利用一会计算军之后的影像和没有计算的影像进行相减操作。
var meanDict = image.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: region,
scale: scale,//如果知道影像分辨率这里可以直接写 例如 :30
maxPixels: 1e9//最大像素值
});
//统计影像中的定值.constant(获取meanDict中各个波段计算出来的均值)
var means = ee.Image.constant(meanDict.values(bandNames));
var centered = image.subtract(means);
print("means",means)
print("centered",centered)
计算结果图: