使用Google Earth引擎将多边形中每个像素的每日价值汇总为每月

问题描述

我正在Google Earth引擎上为多边形处理NASA NEX-GDDP数据。此数据具有三个变量:prtasmintasmax,并且是每日分辨率。对于每天的变量,直到2005年都有21张图像,从2005年开始有42张图像。

我的目标是为每个多边形中每个网格的每个变量计算每年的月总和(对于pr和月平均值(对于tasmintasmax)一天中的单个图片。因此,对于给定的变量,最终输出中的单行应如下所示:

 lat    long     month    year   ACCESS1-0' 'bcc-csm1-1'  'BNU-ESM'  'GFDL-ESM2M' ...... 'norESM1-M' 
 8.125  108.875   1       1950   350          380           320         333                 322

我采用的方法是为每个变量写出每个纬度的每日值,然后 为了总结出每日价值,我使用了以下方法

 // define which variable I want 
 var myvar = 'pr'

 // define my polygon
 var polygon = ee.Geometry.polygon([120,-6,120,8,99,-6]);

 // Define a start and end date
  
 var startDate = ee.Date('2006-01-01');
 var endDate = ee.Date('2018-01-01');
  
 // Filter the image collection by date range,polygon and variable
 var dataset = ee.ImageCollection('NASA/NEX-GDDP')
               .filter(ee.Filter.date(startDate,endDate))
               .filter(ee.Filter.bounds(polygon))
               .select(myvar);
  
 var dailyImg = dataset.toBands();

 var collection = dailyImg.sample({
   region: polygon,geometries: true,});
  
 // Break point coordinates up into properties (table columns) explicitly.
 var collection_with_latlon = collection.map(function (feature) {
 var coordinates = feature.geometry().transform('epsg:4326').coordinates();
   return feature.set('lon',coordinates.get(0),'lat',coordinates.get(1));
  });
  
Export.table.toDrive({
   collection: collection_with_latlon,description: 'tx_2006_2017',fileFormat: 'CSV',});
  

结果文件中的每一行都是来自polygon的纬度,并且日期按列排列。因此,我的列数是天数* 21 GCM。如果增加天数,此表的列方向将非常大

如何编写输出以使每一行都是经/纬度和一天的组合?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)