在 Google Earth Engine 中,可以使用 'image().paint()' 函数将 FeatureCollection 转换为 Image。下面是一个示例代码,演示了如何将 FeatureCollection 转换为二进制影像,其中每个像素的值表示该像素是否在 FeatureCollection 中存在。

// 加载 FeatureCollection
var fc = ee.FeatureCollection('users/yourUsername/yourFeatureCollection');

// 创建一个空白影像
var emptyImage = ee.Image().byte();

// 使用 paint 函数将 FeatureCollection 转换为影像
var filledImage = emptyImage.paint(fc, 'presence');

// 打印结果
print('Filled Image', filledImage);

// 可视化结果
Map.addLayer(filledImage, {palette: 'FF0000'}, 'Filled Image');

在上述代码中,你需要将 'users/yourUsername/yourFeatureCollection' 替换为你自己的 FeatureCollection 的路径。'paint()' 函数将 FeatureCollection 中的几何图形绘制在影像上,并使用指定的属性(在示例中为 'presence')来为像素赋值。在此示例中,我们使用了红色调色板来可视化结果,你可以根据需要更改调色板。

GEE 将 FeatureCollection 转化为 Image

原文地址: https://www.cveoy.top/t/topic/fb5B 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录