累计费用映射

使用 image.cumulativeCost() 计算成本映射,其中每个像素都包含到最近来源位置的最小费用路径的总费用。此过程在各种情境中都很有用,例如栖息地分析(Adriaensen et al. 2003)、流域划定(Melles et al. 2011) 和图像分割(Falcao et al. 2004)。对图片调用累计费用函数,其中每个像素代表穿越该图片的每米费用。路径是通过像素的八个邻居中的任意一个计算得出的。必需的输入包括 source 图片(其中每个非零像素都代表一个可能的来源 [或路径的起点])和用于计算路径的 maxDistance(以米为单位)。该算法会查找长度小于 maxPixels = maxDistance/scale 的所有路径的累计代价,其中 scale 是像素分辨率,或 Earth Engine 中的分析比例

以下示例演示了如何计算土地覆盖图像中的费用最低路径:

Code Editor (JavaScript)

// A rectangle representing Bangui, Central African Republic.
var geometry = ee.Geometry.Rectangle([18.5229, 4.3491, 18.5833, 4.4066]);

// Create a source image where the geometry is 1, everything else is 0.
var sources = ee.Image().toByte().paint(geometry, 1);

// Mask the sources image with itself.
sources = sources.selfMask();

// The cost data is generated from classes in ESA/GLOBCOVER.
var cover = ee.Image('ESA/GLOBCOVER_L4_200901_200912_V2_3').select(0);

// Classes 60, 80, 110, 140 have cost 1.
// Classes 40, 90, 120, 130, 170 have cost 2.
// Classes 50, 70, 150, 160 have cost 3.
var beforeRemap = [60, 80, 110, 140,
                   40, 90, 120, 130, 170,
                   50, 70, 150, 160];
var afterRemap = [1, 1, 1, 1,
                  2, 2, 2, 2, 2,
                  3, 3, 3, 3];
var cost = cover.remap(beforeRemap, afterRemap, 0);

// Compute the cumulative cost to traverse the land cover.
var cumulativeCost = cost.cumulativeCost({
  source: sources,
  maxDistance: 80 * 1000  // 80 kilometers
});

// Display the results
Map.setCenter(18.71, 4.2, 9);
Map.addLayer(cover, {}, 'Globcover');
Map.addLayer(cumulativeCost, {min: 0, max: 5e4}, 'accumulated cost');
Map.addLayer(geometry, {color: 'FF0000'}, 'source geometry');

结果应如下图 1 所示,其中每个输出像素代表到最近来源的累积代价。请注意,在到最近来源的最小代价路径的长度超过 maxPixels 的地方可能会出现不连续性。

costMap
图 1. 源像素的累计成本,其中成本由土地覆盖类别决定。费用较低时为黑色,费用较高时为白色。