我们如何进行NDVI和EVI指数的图表展示,我们可以通过建立一个函数NDVI和EVI,然后用map遍历每一期影像,从而实现图表的展示,这我们使用sentinel2影像进行分析。
Sentinel-2卫星是由欧洲空间局(ESA)和欧洲联盟开发的一个卫星系统,它可以提供高分辨率和高质量的地球观测数据,特别是在多光谱图像方面。
以下是Sentinel-2卫星影像的相关信息:
函数:
setOptions(options)
Sets options used to style this chart.
Returns this chart.
this:ui.chart (ui.Chart):
The ui.Chart instance.
options (Object):
An object defining chart style options such as:
ui.Chart.image.series(imageCollection, region, reducer, scale, xProperty)
Generates a Chart from an ImageCollection. Plots derived values of each band in a region across images. Usually a time series.
Returns a chart.
imageCollection (ImageCollection):
An ImageCollection with data to be included in the chart.
region (Feature|FeatureCollection|Geometry):
The region to reduce.
reducer (Reducer, optional):
Reducer that generates the values for the y-axis. Must return a single value. Defaults to ee.Reducer.mean().
scale (Number, optional):
Scale to use with the reducer in meters.
xProperty (String, optional):
Property to be used as the label for each image on the x-axis. Defaults to 'system:time_start'.
代码:
var geometry =
/* color: #d63000 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[113.12962886187917, -8.101032847560129],
[113.12962886187917, -8.12754392211754],
[113.16533442828542, -8.12754392211754],
[113.16533442828542, -8.101032847560129]]], null, false);
var S2A = ee.ImageCollection('COPERNICUS/S2_SR').filterDate('2021-01-01','2022-01-01').filterBounds(geometry);
// print(S2A);
var getIndices=function(image){
var NDVI = image.normalizedDifference(['B8', 'B4']).rename('NDVI');
var EVI = image.expression('2.5 * ((NIR - RED) / (NIR + 2.4 * RED + 1))',
{
'NIR': image.select('B8'),
'RED': image.select('B4')
}).rename('EVI');
return image.addBands([NDVI,EVI]);
};
var collection=S2A.map(getIndices);
// print(collection);
var chartEVI = ui.Chart.image.series({
imageCollection: collection.select('EVI'),
region: geometry,
reducer: ee.Reducer.mean(),
scale: 20
}).setOptions({
title: 'Original EVI Time Series',
interpolateNulls: false,
vAxis: {title: 'EVI', viewWindow: {min: 0, max: 1}},
hAxis: {title: '', format: 'YYYY-MM'},
lineWidth: 1,
pointSize: 4,
series: {
0: {color: '#238b45'},
},
})
print(chartEVI);
var chartNDVI = ui.Chart.image.series({
imageCollection: collection.select('NDVI'),
region: geometry,
reducer: ee.Reducer.mean(),
scale: 20
}).setOptions({
title: 'Original EVI Time Series',
interpolateNulls: false,
vAxis: {title: 'EVI', viewWindow: {min: 0, max: 1}},
hAxis: {title: '', format: 'YYYY-MM'},
lineWidth: 1,
pointSize: 4,
series: {
0: {color: '#238b45'},
},
})
print(chartNDVI);