GEE(Google Earth Engine)如何获取影像像素均值和栅格计算?

ee.Image.constant(value)

Generates an image containing a constant value everywhere.

生成一个在任何地方都包含一个常量值的图像

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.

恒定图像中像素的值。必须是数字或数组或数字列表或数组

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.

以列表形式返回字典的值。如果未指定键,则所有值都以字典键的自然顺序返回。主要是你影像当中的波段你是否乱序,如果没有乱序的化就按照默认就欧克,在下面的例子中我是将所有的影像波段都以列表的形式传送个一个变量。

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.

对于 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

最后看代码:

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)

计算结果图:

  • 2
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值