简体   繁体   English

在 Google Earth Engine 中汇总图像集合中每张图像的像素值

[英]Summarize Pixel Value in Every Image of an Image Collection in Google Earth Engine

I am a newbie in GEE.我是 GEE 的新手。 I want to calculate a sum / mean of a pixel value (rainfall data from CHIRPS satellite) in one region of every image data in an ImageCollection.我想计算 ImageCollection 中每个图像数据的一个区域中像素值(来自 CHIRPS 卫星的降雨数据)的总和/平均值。 Basically i want to calculate the mean daily rainfall in my study area.基本上我想计算我研究区域的平均日降雨量。

Here is my code so far:到目前为止,这是我的代码:

//define study area
var aoi = ee.FeatureCollection(juana)

//load & filtering ImageCollection
var precipitation = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
.filterDate('2021-01-01', '2021-12-31')
.select('precipitation');

//clipped ImageCollection to Study Area
var clipped = precipitation.map(function(precipitation){
return precipitation.clip(aoi);
});

//plot in map
Map.addLayer(clipped)

Here is the result in map:这是 map 中的结果: 在此处输入图像描述

Every pixel has a daily rainfall data like this:每个像素都有这样的每日降雨数据: 在此处输入图像描述

But what i need is i want to sum/averaging those pixel in the study area and make a daily graphic.但我需要的是我想对研究区域中的那些像素求和/平均并制作每日图形。 What should i do?我应该怎么办?

You use ee.Image().reduceRegion() to calculate aggregate statistics for an area of an image.您使用ee.Image().reduceRegion()来计算图像区域的聚合统计信息。 In your case, you want a time-series of the stats, so you want to do this for every image in you collection.在你的例子中,你想要一个时间序列的统计数据,所以你想对你收藏中的每张图片都这样做。 To do that, you use ee.ImageCollection.map() .为此,您可以使用ee.ImageCollection.map() You have relevant sections in the docs here and here .您在此处此处的文档中有相关部分。 Something like this:是这样的:

var dailyStats = precipitation.map(function (image) {
  var reduced = image.reduceRegion({
    reducer: ee.Reducer.sum()
      .combine(ee.Reducer.mean(), null, true), 
    geometry: aoi.geometry(), 
    scale: 5000, 
    maxPixels: 1e13
  })
  return ee.Feature(null, reduced)
    .set('system:time_start', image.get('system:time_start'))
})

var meanChart = ui.Chart.feature.byFeature({
  features: dailyStats,
  xProperty: 'system:time_start', 
  yProperties: 'precipitation_mean'
})

var sumChart = ui.Chart.feature.byFeature({
  features: dailyStats,
  xProperty: 'system:time_start', 
  yProperties: 'precipitation_sum'
})
print('mean', meanChart)
print('sum', sumChart)

https://code.earthengine.google.com/e6e4af4147004c6cbd9fe0f20dd7c9fe https://code.earthengine.google.com/e6e4af4147004c6cbd9fe0f20dd7c9fe

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Earth Engine:将波段添加到具有时间平均值的图像集合 - Google Earth Engine: Add band to Image Collection with mean value in time 减少图像集合 Google Earth Engine - Reduction over an image collection Google Earth Engine 导出 Google Earth Engine 图像集合中的所有图像(Google Earth Engine API) - Exporting all images in a Google Earth Engine image collection (Google Earth Engine API) 如何根据其位置在Google Earth Engine中对图像集合进行子集化? - How to subset an image collection in Google Earth Engine based on their position? 导出图像集合 - Landsat-8 表面温度(Google 地球引擎) - Exporting Image Collection - Landsat-8 Surface Temperature (Google Earth Engine) Google Earth Engine:Landsat图像区域 - Google Earth Engine: Region of Landsat Image 遍历图像集合 Google Earth Enigne - Iterate over Image Collection Google Earth Enigne 从 Google 地球引擎中的图像集合中导出图像 - 超出用户 memory 限制 - Exporting images from image collection in Google Earth Engine - user memory limit exceeded 如何使用 Google 地球引擎中的元数据属性为图像集合 select 特定图像? - How to select specific images for an image collection using metadata properties in Google Earth Engine? 使用Google地球引擎将Landsat图像集合减少为长格式列表时缺少ND​​VI值 - Missing NDVI values when reducing Landsat Image Collection to long format list using Google Earth Engine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM