前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >GEE(Google Earth Engine)如何获取影像像素均值和栅格计算?

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

作者头像
此星光明
发布2024-02-01 19:57:22
发布2024-02-01 19:57:22
39300
代码可运行
举报
运行总次数:0
代码可运行

ee.Image.constant(value)

Generates an image containing a constant value everywhere.

代码语言:javascript
代码运行次数:0
复制
生成一个在任何地方都包含一个常量值的图像
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
代码运行次数:0
复制
恒定图像中像素的值。必须是数字或数组或数字列表或数组
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
代码运行次数:0
复制
以列表形式返回字典的值。如果未指定键,则所有值都以字典键的自然顺序返回。主要是你影像当中的波段你是否乱序,如果没有乱序的化就按照默认就欧克,在下面的例子中我是将所有的影像波段都以列表的形式传送个一个变量。
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
代码运行次数:0
复制
对于 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
代码运行次数:0
复制
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)

计算结果图:

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2024-02-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Arguments:
  • Returns: Image
  • Arguments:
  • Returns: List
  • Arguments:
  • Returns: Image
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档