在谷歌地球引擎中对范围进行重新分类



我想对全球森林数据值进行重新分类,即

0 - 20 % --> 1

21 - 49 % --> 0.5

50 - 100 % --> 0

但是,我无法找到如何为 GEE 中的范围执行此操作。可以在此处找到重新分类单个数字的说明:

https://sites.google.com/site/globalsnowobservatory/home/Presentations-and-Tutorials/short-tutorial/remap

但是很难找到范围的简单过程(没有决策树(。 有人可以为此提供一个简单的解决方案吗?

// Example from https://developers.google.com/earth-engine/resample
// Load a MODIS EVI image.
var modis = ee.Image(ee.ImageCollection('MODIS/006/MOD13A1').first())
.select('EVI');
// Get information about the MODIS projection.
var modisProjection = modis.projection();
// Load and display forest cover data at 30 meters resolution.
var forest = ee.Image('UMD/hansen/global_forest_change_2015')
.select('treecover2000');
// Get the forest cover data at MODIS scale and projection.
var forestMean = forest
// Force the next reprojection to aggregate instead of resampling.
.reduceResolution({
reducer: ee.Reducer.mean(),
maxPixels: 1024,
bestEffort:true
})
// Request the data at the scale and projection of the MODIS image.
.reproject({
crs: modisProjection
});

如果要对像素值做出二进制决策,可以使用 ee。Image.where(( 算法。它采用布尔值的图像来指定图像中用另一个图像替换像素的位置。在此应用程序中使用它的最整洁方法是使用ee.Image.expression()语法(而不是指定多个布尔和常量图像(:

var reclassified = forestMean.expression('b(0) <= 20 ? 1 : b(0) < 50 ? 0.5 : 0');

b(0)是指输入图像第一个波段的值,? ... :是 ?: 条件运算符,如果左侧的条件为真,则返回?:之间的部分,如果条件为假,则返回:右侧的部分。因此,您可以使用一系列? ... :简洁地写出几个条件。

此行的可运行示例。

最新更新