问题描述
当我使用 Google 地球引擎时,出现错误。 1.我使用 MOdis 叶面积指数产品 MOD15A2H 来计算每年的年度 LAI 最大值。 2.使用ee.Reducer.ridgeRegression得到回归系数图。 3.使用特征统计系数(例如平均值或最小最大值),在这一步产生错误(字典(错误):发生内部错误。但是当我在步骤1中时,我更改了ImageCollection以获得Annual LAI 每年的平均值不是最大值,整个代码是正确的。 代码:https://code.earthengine.google.com/115972267dc75b9247919d340672f577
当前行为
预期行为
*像这样获取正确的字典:
- 对象(4 个属性) LAI_Year_max: 0.06816618889570236 LAI_Year_min:-0.0584731325507164 constant_Year_max:3.3569486141204834 constant_Year_min:-2.2856149673461914
var mod15a2h = ee.ImageCollection("MOdis/006/MOD15A2H");
var mod15a2h = ee.ImageCollection("MOdis/006/MOD15A2H");
///******************** Function ***********************
// Calculate the band mean value of year
function product_annual_mean(Product_collection,Band,YearList,Region,Scale,Offset) {
var images = YearList.map(function(year){
var year_filter = ee.Filter.calendarRange(year,year,'year');
var image_yearly = Product_collection.filter(year_filter)
.select(Band)
.map(function(image){return image.clip(Region.geometry())})
.mean()
.multiply(Scale)
.add(Offset);
image_yearly = image_yearly.set("system:index",ee.String(ee.Number(year).toInt()));
image_yearly = image_yearly.set("system:time_start",ee.Date(ee.String(ee.Number(year).toInt())).millis());
return image_yearly;
});
return ee.ImageCollection.fromImages(images);
}
//
function product_annual_max(Product_collection,'year');
var image_yearly = Product_collection.filter(year_filter)
.select(Band)
.map(function(image){return image.clip(Region.geometry())})
.max()
.multiply(Scale)
.add(Offset);
image_yearly = image_yearly.set("system:index",ee.Date(ee.String(ee.Number(year).toInt())).millis());
return image_yearly;
});
return ee.ImageCollection.fromImages(images);
}
// This function adds a time band to the image.
var createTimeBand = function(image) {
// Scale milliseconds by a large constant to avoid very small slopes
// in the linear regression output.
return image.addBands(image.Metadata('system:time_start','Year')
.divide(1000 * 60 * 60 * 24 * 365));
};
// This function adds a constant band to the image.
var createConstantBand = function(image) {
return ee.Image(1).addBands(image);
};
// // //=========================================================================================
// Create an ee.Geometry.
// Create a Feature from the Geometry.
var region = ee.Feature(ee.Geometry.polygon([
[[95.5,37.5],[102.5,40.5],[95.5,37.5]]
]));
var start_year = 2001;
var end_year = 2019;
var yearList = ee.List.sequence(start_year,end_year);
var product =mod15a2h;
var band = 'Lai_500m';
var scale = 0.1;
var offset = 0;
// Use the Mean Leaf area index is ok
var annual_max_LAI = product_annual_max(product,band,yearList,region,scale,offset);
// Load the input image collection and Map the time band function over the collection.
var modisLAI_col = annual_max_LAI.map(createTimeBand);
print('LAI annual mean Collection',modisLAI_col.first());
/* ==========================================================================================================
* ----------------- ee.Reducer.ridgeRegression() ------------------------------------------------------
* Creates a reducer that computes a ridge regression with numX independent variables (not including constant)
* followed by numY dependent variables. Ridge regression is a form of Tikhonov regularization which shrinks
* the regression coefficients by imposing a penalty on their size. With this implementation of ridge regression
* there NO NEED to include a constant value for bias.
*/
var ridgeRegression = modisLAI_col.map(createConstantBand).select(['Year',band])
.reduce(ee.Reducer.ridgeRegression(1,1));
print('ee.Reducer.ridgeRegression()',ridgeRegression);
// These lists label the @R_604_4045@ion along each axis of the arrays.
// var bandNames = [['Lai_500m','constant'],['Year']]; // 0-axis variation.,var bandNames = [['constant','LAI'],var ridgeRegression_coefficients_Img = ridgeRegression.select('coefficients').arrayFlatten(bandNames);
print('ridgeRegression_coefficients_Img',ridgeRegression_coefficients_Img);
var bandNames_pValue = [[ 'pValue']]; // 0-axis variation.,var ridgeRegression_pValue_Img = ridgeRegression.select('pValue').arrayFlatten(bandNames_pValue);
// This Step is wrong(Dictionary (Error)An internal error has occurred (request: 7a9f8202-a6ae-460c-8026-8d79dad169e3))
print('Max LAI ridgeRegression coefficients min-Max',ee.Image(ridgeRegression_coefficients_Img)
.reduceRegion({
reducer:ee.Reducer.minMax(),geometry:region.geometry(),scale:1000,maxPixels: 1e13,bestEffort: true
}));
// ============================================================================================================
// Use the Mean Leaf area index is ok
var annual_mean_LAI = product_annual_mean(product,offset);
// Load the input image collection and Map the time band function over the collection.
var modisLAI_col = annual_mean_LAI.map(createTimeBand);
print('LAI annual mean Collection',var ridgeRegression_pValue_Img = ridgeRegression.select('pValue').arrayFlatten(bandNames_pValue);
// This Step is ok
print('Mean Leaf Area Index ridgeRegression coefficients min-Max',bestEffort: true
}));
// ==========================================================================
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)