【问题标题】:Reclassify ranges in Google Earth Engine在 Google 地球引擎中重新分类范围
【发布时间】:2020-05-07 12:24:18
【问题描述】:

我想重新分类全球森林数据值,即喜欢

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
    });

【问题讨论】:

标签: google-earth-engine


【解决方案1】:

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

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

b(0)指的是输入图像的第一个波段的值,? ... :?: conditional operator,如果左边的条件为真,则返回?:之间的部分,并且如果条件为假,: 右侧的部分。所以,你可以用一串? ... :简洁地写出几个条件。

Runnable example with this line.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-18
    • 2018-08-24
    • 2018-10-17
    • 2017-10-07
    • 2019-05-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多