Google Earth Engine 中栅格的比例值

Scale values of raster in Google Earth Engine

我想在 Google Earth Engine 中使用地图代数合并多个图层。但是,我需要将它们缩放为具有 1-5 个值,以便它们具有可比性。这是一层的示例,坡度,我需要将其缩放到 1-5 范围内的值。

// Load the SRTM image.
var srtm = ee.Image('CGIAR/SRTM90_V4');

// Apply an algorithm to an image.
var slope = ee.Terrain.slope(srtm);

var Vis = {
  min: 1.0,
  max: 30.0,
  palette: ['001137', '0aab1e', 'e7eb05', 'ff4a2d', 'e90000'],
};
Map.setCenter(-74.93, 4.71, 5);


// Display the result.
 // Center on the Grand Canyon.
Map.addLayer(slope, Vis, 'slope');

我会使用 unitScale 首先获得 0 - 1 范围内的斜率,然后乘以 4,得到 0 - 4 ...如果你想要 1-5,只需加 1最后:

var slope2 = slope.unitScale(0,90).multiply(4).add(1)

在这种情况下,我使用 0 和 90 来缩放图像,这是完整的理论范围...根据您的 AOI,您可能希望使用较小的范围。