之前总结的Modis_NDVI数据分析的博客链接如下:
《GEE开发之Modis_NDVI的数据分析》
《GEE开发之MODIS_NDVI年均值数据分析》
《GEE开发之MODIS_NDVI一年之中的所有数据获取》
//以鹿邑为例子
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
//选取影像集以及波段 NDVI
var ndvi = ee.ImageCollection("MODIS/006/MYD13Q1").filterDate('2020-01-01', '2020-12-31').filterBounds(geometry).select("NDVI");
//换算单位
var multiply = function(image){
var img = image.multiply(0.0001);
return img.set('system:time_start',image.get('system:time_start'));
};
ndvi = ndvi.map(multiply);
print(ndvi);
//设置调色板并展示影像
var colorizedVis = {min: 0.0, max: 1.0, palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']};
Map.addLayer(ndvi.median().clip(geometry), colorizedVis, 'NDVI');//2020年NDVI的均值
//以鹿邑为例子
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
//选取影像集以及波段 NDVI
var ndvi = ee.ImageCollection("MODIS/MOD09GA_006_NDVI").filterDate('2020-01-01', '2020-12-31').filterBounds(geometry).select("NDVI");
print(ndvi);
//设置调色板并展示影像
var colorizedVis = {min: 0.0, max: 1.0, palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']};
Map.addLayer(ndvi.median().clip(geometry), colorizedVis, 'NDVI');//2020年NDVI的均值
//以鹿邑为例子
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
//选取影像集以及波段 NDVI
var ndvi = ee.ImageCollection("MODIS/006/MOD13Q1").filterDate('2020-01-01', '2020-12-31').filterBounds(geometry).select("NDVI");
//换算单位
var multiply = function(image){
var img = image.multiply(0.0001);
return img.set(image.toDictionary(image.propertyNames()));
};
ndvi = ndvi.map(multiply);
print(ndvi);
//设置调色板并展示影像
var colorizedVis = {min: 0.0, max: 1.0, palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']};
Map.addLayer(ndvi.median().clip(geometry), colorizedVis, 'NDVI');
//以鹿邑为例子
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
//选取影像集以及波段 NDVI
var ndvi = ee.ImageCollection("MODIS/006/MOD13A1").filterDate('2020-01-01', '2020-12-31').filterBounds(geometry).select("NDVI");
//换算单位
var multiply = function(image){
var img = image.multiply(0.0001);
return img.set(image.toDictionary(image.propertyNames()));
};
ndvi = ndvi.map(multiply);
print(ndvi);
//设置调色板并展示影像
var colorizedVis = {min: 0.0, max: 1.0, palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']};
Map.addLayer(ndvi.median().clip(geometry), colorizedVis, 'NDVI');
//以鹿邑为例子
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
//选取影像集以及波段 NDVI
var ndvi = ee.ImageCollection("MODIS/006/MOD13A2").filterDate('2020-01-01', '2020-12-31').filterBounds(geometry).select("NDVI");
//换算单位
var multiply = function(image){
var img = image.multiply(0.0001);
return img.set(image.toDictionary(image.propertyNames()));
};
ndvi = ndvi.map(multiply);
print(ndvi);
//设置调色板并展示影像
var colorizedVis = {min: 0.0, max: 1.0, palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']};
Map.addLayer(ndvi.median().clip(geometry), colorizedVis, 'NDVI');//NDVI均值显示
//以鹿邑为例子
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
//选取影像集以及波段 NDVI
var ndvi = ee.ImageCollection("MODIS/006/MYD13Q1").filterDate('2020-01-01', '2020-12-31').select("NDVI");
//换算单位
var multiply = function(image){
var img = image.multiply(0.0001);
return img.set('system:time_start',image.get('system:time_start'));
};
ndvi = ndvi.map(multiply);
//设置调色板并展示影像
var colorizedVis = {min: 0.0, max: 1.0, palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']};
print(ndvi);
function exportImageCollection(imgCol) {
var indexList = imgCol.reduceColumns(ee.Reducer.toList(), ["system:index"]).get("list");
indexList.evaluate(function(indexs) {
for (var i=0; i<indexs.length; i++) {
var image = imgCol.filter(ee.Filter.eq("system:index", indexs[i])).first();
image = image.clip(geometry);
Map.addLayer(image, colorizedVis, indexs[i]);//查看具体的遥感影像
//tif数据下载
Export.image.toDrive({
image: image,
description: 'modis_ndvi_'+indexs[i],
fileNamePrefix: 'modis_ndvi_'+indexs[i],
folder: 'Modis',
region: geometry,
scale: 250,
crs: "EPSG:4326",
maxPixels: 1e13
});
}
});
}
exportImageCollection(ndvi);
//以鹿邑为例子
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
//选取影像集以及波段 NDVI
var ndvi = ee.ImageCollection("MODIS/006/MYD13Q1").filterDate('2020-01-01', '2020-12-31').select("NDVI");
//换算单位
var multiply = function(image){
var img = image.multiply(0.0001);
return img.set('system:time_start',image.get('system:time_start'));
};
ndvi = ndvi.map(multiply);
//设置调色板并展示影像
var colorizedVis = {min: 0.0, max: 1.0, palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']};
//时间范围
var years = ee.List.sequence(2020, 2020);
var months = ee.List.sequence(1, 12);
//将逐日数据生成月平均数据
var monthlymeanNDVI = ee.ImageCollection.fromImages(
years.map(function (y) {
return months.map(function(m) {
return ndvi.filter(ee.Filter.calendarRange(y,y, 'year')).filter(ee.Filter.calendarRange(m, m, 'month')).mean().set('year', y).set('month', m).set('system:time_start', ee.Date.fromYMD(y, m, 1));
});
}).flatten());
print(monthlymeanNDVI)
function exportImageCollection(imgCol) {
var indexList = imgCol.reduceColumns(ee.Reducer.toList(), ["system:index"]).get("list");
indexList.evaluate(function(indexs) {
for (var i=0; i<indexs.length; i++) {
var image = imgCol.filter(ee.Filter.eq("system:index", indexs[i])).first();
image = image.clip(geometry);
Map.addLayer(image, colorizedVis, indexs[i]);//查看具体的遥感影像
//tif数据下载
Export.image.toDrive({
image: image,
description: 'modis_ndvi_'+indexs[i],
fileNamePrefix: 'modis_ndvi_'+indexs[i],
folder: 'Modis',
region: geometry,
scale: 250,
crs: "EPSG:4326",
maxPixels: 1e13
});
}
});
}
exportImageCollection(monthlymeanNDVI);
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
var NDVI =ee.ImageCollection("MODIS/006/MYD13Q1");
for(var i=2018;i<=2020;i++){
for(var j=1;j<=12;j++){
var data_collection = null;
switch(j){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
data_collection = NDVI.filterDate(i+'-'+j+'-01',i+'-'+j+'-31').select('NDVI');
break;
case 4:
case 6:
case 9:
case 11:
data_collection = NDVI.filterDate(i+'-'+j+'-01',i+'-'+j+'-30').select('NDVI');
break;
case 2:
data_collection = NDVI.filterDate(i+'-'+j+'-01',i+'-'+j+'-28').select('NDVI');
break;
}
// print(data_collection)
var YR_collection = data_collection.mean().multiply(0.0001).clip(geometry);
// print(YR_collection)
Export.image.toDrive({
image: YR_collection,
description: i+'-'+j,
fileNamePrefix: i+'-'+j,
scale: 250,
region: geometry,
maxPixels: 1e13,
folder: 'Modis'
})
}
}
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
// 选择数据集并进行波段比例换算
var collection = ee.ImageCollection("MODIS/006/MOD13Q1").filterDate('2000-01-01', '2020-12-31').select("NDVI");
//换算单位
var multiply = function(image){
var img = image.multiply(0.0001);
return img.set(image.toDictionary(image.propertyNames()));
};
collection = collection.map(multiply);
//进行年平均值的计算
var years = ee.List.sequence(2000, 2020);
var collectYear = ee.ImageCollection(years
.map(function(y) {
var start = ee.Date.fromYMD(y, 1, 1);
var end = start.advance(12, 'month');
return collection.filterDate(start, end).reduce(ee.Reducer.mean()).float().set('system:time_start',y).set('year',y);
}));
print(collectYear);
//年均值的时间序列展示
var Yearly_chart = ui.Chart.image.series({
imageCollection: collectYear.select('NDVI_mean'),
region: geometry,
reducer: ee.Reducer.mean(),
scale: 500,
xProperty: 'year',
}).setOptions({
interpolateNulls: true,
lineWidth: 2,
title: 'NDVI Yearly Seires',
vAxis: {title: 'NDVI'},
hAxis: {title: 'Date'},
//trendlines: { 0: {title: 'NDVI_trend',type:'linear', showR2: true, color:'red', visibleInLegend: true}}
});
print(Yearly_chart);
var colorizedVis = {min: 0.0, max: 1.0, palette: ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301']};
function exportImageCollection(imgCol) {
var indexList = imgCol.reduceColumns(ee.Reducer.toList(), ["system:index"]).get("list");
indexList.evaluate(function(indexs) {
for (var i=0; i<indexs.length; i++) {
var image = imgCol.filter(ee.Filter.eq("system:index", indexs[i])).first();
image = image.clip(geometry);
Map.addLayer(image, colorizedVis, indexs[i]);//查看具体的遥感影像
//tif数据下载
Export.image.toDrive({
image: image,
description: 'modis_ndvi_'+indexs[i],
fileNamePrefix: 'modis_ndvi_'+indexs[i],
folder: 'Modis',
region: geometry,
scale: 250,
crs: "EPSG:4326",
maxPixels: 1e13
});
}
});
}
exportImageCollection(collectYear);
var geometry = ee.FeatureCollection('users/www1573979951/luyixian');
Map.centerObject(geometry,6);
var NDVI =ee.ImageCollection("MODIS/006/MYD13Q1");
for(var i=2018;i<=2020;i++){
var data_collection = NDVI.filterDate(i+'-01-01',i+'-12-31').select('NDVI');
print(data_collection)
var YR_collection = data_collection.mean().multiply(0.0001).clip(geometry);
Export.image.toDrive({
image: YR_collection,
description: i,
fileNamePrefix: i,
scale: 250,
region: geometry,
maxPixels: 1e13,
folder: 'Modis'
});
}