【问题标题】:how to choose a specific single image in GGEGGE中如何选择特定的单张图片
【发布时间】:2023-01-26 03:47:13
【问题描述】:

使用此代码,GGE 获得了 2022 年最少云的图像,但我需要计算特定图像 (2022-07-20) 中的 NDVI。我应该改变什么? 如果我尝试在 filter.Date 中指定日期,代码将不起作用。 .filterDate('2022-07-20')

错误是: NDVI 图像:图层错误:Image.select,参数“输入”:无效类型。 预期类型:图像。 实际类型:ImageCollection。

var point = ee.Geometry.Point([8.73727, 45.81165]);

// Import the Sentinel-2 image collection.
var S2 = ee.ImageCollection("COPERNICUS/S2")

// Get the least cloudy image in 2022.
 var image = ee.Image(
 S2.filterBounds(point)
.filterDate('2022-01-01', '2022-12-31')
.sort('CLOUD_COVER')
.first()
 );


// Compute the Normalized Difference Vegetation Index (NDVI).
var nir = image.select('B8');
var red = image.select('B4');
var ndvi = nir.subtract(red).divide(nir.add(red)).rename('NDVI');

// Display the result.
Map.centerObject(image, 9);
var ndviParams = {min: -1, max: 1, palette: ['blue', 'white', 'green']};
Map.addLayer(ndvi, ndviParams, 'NDVI image');

【问题讨论】:

  • 刚刚运行你的代码,你提到的错误没有显示。

标签: javascript google-earth-engine


【解决方案1】:

过滤器函数以“ee.Filter.date(start, end)”作为开始和结束日期。由于您已经知道您想要的日期并且 Sentinel-2 重新访问时间不是每天(而是 10 天),您可以像这样以 1 天的间隔应用过滤器:

.filterDate('2022-07-20', '2022-07-21')

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    • 2020-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多