Google Earth Engine学习笔记(二)

Google Earth Engine学习笔记(二)


Object-based methods(面向对象方法)

原文

For treating landscape elements as objects, Earth Engine contains several methods. Specifically, when an image has distinct patches identified by unique pixel values, use image.connectedPixelCount() to compute the number of pixels in each patch and image.connectedComponents() to label each patch with a unique identifier. The unique identifiers can then be used to enumerate the patches and analyze the distribution of size or some other quality of interest. The following computes the size and unique identifiers of hot patches in a surface temperature image:

翻译

为了将景观元素视为对象,Earth Engine包含多种方法。具体而言,当图像具有由唯一像素值标识的不同patch时,可以使用 image.connectedPixelCount()计算每个补丁中的像素数并使用 image.connectedComponents()方法计算每个patch的唯一标识符标记。然后,可以使用唯一标识符来枚举patch并分析大小的分布或一些其他感兴趣的方面。以下计算表面温度图像中hot patch的大小和唯一标识符:

代码

// Load a Landsat 8 image and display the thermal band.
var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20140318');
Map.setCenter(-122.1899, 37.5010, 13); // SF Bay
Map.addLayer(image, {bands: ['B10'], min: 270, max: 310}, 'LST');

// Threshold the thermal band to find "hot" objects.
var hotspots = image.select('B10').gt(303);

// Mask "cold" pixels.
hotspots = hotspots.updateMask(hotspots);
Map.addLayer(hotspots, {palette: 'FF0000'}, 'hotspots');

// Compute the number of pixels in each patch.
var patchsize = hotspots.connectedPixelCount(256, false);
Map.addLayer(patchsize, {}, 'patch size');

// Uniquely label the patches and visualize.
var patchid = hotspots.connectedComponents(ee.Kernel.plus(1), 256);
Map.addLayer(patchid.randomVisualizer(), {}, 'patches');
    

说明

In the previous example, note that the maximum patch size is set to 256 pixels by the arguments to the connectedPixelCount() and connectedComponents() methods. The connectivity is also specified by the arguments, in the former method by a boolean and in the latter method by an ee.Kernel. In this example, only four neighbors are considered for each pixel.
在前面的示例中,请注意,connectedPixelCount()和和connectedComponents() 方法的参数将最大patch的大小设置为256像素。connectivity参数也被指定,在前一个方法中由布尔值指定,后一个方法由一个ee.Kernel指定。在该示例中,对于每个像素仅考虑四个相邻像素。

结果

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值