【发布时间】:2021-07-22 15:12:31
【问题描述】:
我正在从资产中导入 2 个不同的 shapefile 来绘制 MODIS 的时间序列图
但我无法从这些 shapefile 中收集特征
怎么做?
var Haryana_state = ee.FeatureCollection('users/abhilashaanu92/HaryanaBoundary');
Map.addLayer(Haryana_state);
var Punjab_state = ee.FeatureCollection('users/abhilashaanu92/punjab_state_boundary');
Map.addLayer(Punjab_state);
// Combine features into a feature collection.
var both_states = ee.FeatureCollection([Haryana_state, Punjab_state]).flatten();
Map.addLayer(both_states);
// Load MODIS vegetation indices data and subset annual images.
var vegIndices = ee.ImageCollection('MODIS/006/MOD13A1')
.filter(ee.Filter.date('2019-01-01', '2020-01-01'))
.select(['NDVI', 'EVI']);
// Define the chart and print it to the console.
var chart =
ui.Chart.image
.seriesByRegion({
imageCollection: vegIndices,
band: 'NDVI',
regions: both_states,
reducer: ee.Reducer.mean(),
scale: 500,
seriesProperty: 'label',
xProperty: 'system:time_start'
})
.setOptions({
title: 'Average NDVI Value by Date',
hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
vAxis: {
title: 'NDVI (x1e4)',
titleTextStyle: {italic: false, bold: true}
},
lineWidth: 5,
colors: ['f0af07', '0f8755', '76b349'],
});
print(chart);
如果我将单个 shapefile 变量的名称放在区域中,那么它可以工作,但是当我将 2 个 shapefile 组合到一个特征集合中时,它会显示错误。
如何解决这个问题?
我想要输出这样的东西。 (同一图表上两种状态的时间序列)。
【问题讨论】:
标签: javascript google-earth-engine