var roi = JIzhongnan;
Map.centerObject(roi, 6);
var luancheng= ee.Geometry.Point(114.689,37.884);
Map.addLayer(luancheng);
//study year
var yearNum = 2011;
var start_date = ee.Date(‘2011-06-09’);
var setps = ee.Number(15); ///////////////////// update_1
var end_date = ee.Date(‘2011-06-10’).advance(setps.multiply(8),‘day’);
var filter_date = ee.Filter.date(start_date, end_date);
// print(filter_date);
// bug
var daysOfYear = ee.Date.fromYMD(yearNum, 1, 1).advance(1,‘year’).difference(ee.Date.fromYMD(yearNum, 1, 1),‘day’);
var days = ee.List.sequence(1, daysOfYear, 8); //daysOfYear
// print(days);bug
// var SM_set = image;//(next)
// print(image);bug
//------------- soil moisture from GLDAS -----------//
var GLDAS_rootzone = GLDAS.filter(ee.Filter.calendarRange(yearNum, yearNum,‘year’)) //
.select([‘SoilMoi0_10cm_inst’,‘SoilMoi10_40cm_inst’, ‘SoilMoi40_100cm_inst’]);
var SM_gldas_maizeRoot = GLDAS_rootzone.map(function (img){
var sm_10 = img.select(‘SoilMoi0_10cm_inst’);
var sm_40 = img.select(‘SoilMoi10_40cm_inst’).add(sm_10);
var sm_100 = img.select(‘SoilMoi40_100cm_inst’).add(sm_40);
var sm_root = sm_100;
return sm_root.rename(‘sm_root’).clip(roi).copyProperties({
source: img,
properties: [‘system:index’,‘system:time_start’]
})
});
// print(‘SM_gldas_maizeRoot’, SM_gldas_maizeRoot);
var SM_daily = ee.ImageCollection.fromImages(
days.map(function (d) {
// var date = ee.Date.fromYMD(yearNum, 1, 1).advance(ee.Number(d).subtract(1), ‘day’);//new add
return SM_gldas_maizeRoot
.filter(ee.Filter.calendarRange(d, d, ‘day_of_year’))
.mean()
.clip(roi)
.set(‘system:time_start’, ee.Date.fromYMD(yearNum, 1, 1) //original
// .set(‘system:time_start’, date.millis()) //new add
.advance(ee.Number(d).subtract(1), ‘day’))//original
}).flatten());
print(‘SM_daily’, SM_daily);
//----------export image---------//
var SM = SM_daily.filter(filter_date);
print('SM',SM);
// // bug
var images = SM.toList(SM.size());
var exportToAsset = function(image, index) {
var date = ee.Date(ee.Image(image).get('system:time_start')).format('YYYYMMdd');
var assetName = ee.String('sm_image_').cat(date);
Export.image.toAsset({
image: ee.Image(image).select(['sm_root']),
description: assetName,
assetId: 'projects/ee-wangynov6/assets/maize/SM/SM_GLDAS' + assetName,
region: roi,
scale: 1000,
crs: 'EPSG:4326',
maxPixels: 1e10
});
};
ee.List.sequence(0, images.size().subtract(1)).evaluate(function(length) {
for (var i = 0; i < length.length; i++) {
exportToAsset(images.get(i), i);
}
});
最终export出的image图像是ee.String({ "type": "Invocation", "arguments": { "string1": "sm_image_", "string2": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "value": { "type": "Invocation", "arguments": { "object": { "type": "Invocation", "arguments": { "list": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "images": { "type": "Invocation", "arguments": { "list": { "type": "Invocation", "arguments": { "list": { "type": "Invocation", "arguments": { "start": 1, "end": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "year": 2011, "month": 1, "day": 1 }, "functionName": "Date.fromYMD" }, "delta": 1, "unit": "year" }, "functionName": "Date.advance" }, "start": { "type": "Invocation", "arguments": { "year": 2011, "month": 1, "day": 1 }, "functionName": "Date.fromYMD" }, "unit": "day" }, "functionName": "Date.difference" }, "step": 8 }, "functionName": "List.sequence" }, "baseAlgorithm": { "type": "Function", "argumentNames": [ "_MAPPING_VAR_2_0" ], "body": { "type": "Invocation", "arguments": { "object": { "type": "Invocation", "arguments": { "input": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "id": "NASA/GLDAS/V021/NOAH/G025/T3H" }, "functionName": "ImageCollection.load" }, "filter": { "type": "Invocation", "arguments": { "start": 2011, "end": 2011, "field": "year" }, "functionName": "Filter.calendarRange" } }, "functionName": "Collection.filter" }, "baseAlgorithm": { "type": "Function", "argumentNames": [ "_MAPPING_VAR_0_0" ], "body": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "SoilMoi0_10cm_inst", "SoilMoi10_40cm_inst", "SoilMoi40_100cm_inst" ] }, "functionName": "Image.select" } } }, "functionName": "Collection.map" }, "baseAlgorithm": { "type": "Function", "argumentNames": [ "_MAPPING_VAR_0_0" ], "body": { "type": "Invocation", "arguments": { "destination": { "type": "Invocation", "arguments": { "input": { "type": "Invocation", "arguments": { "input": { "type": "Invocation", "arguments": { "image1": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "SoilMoi40_100cm_inst" ] }, "functionName": "Image.select" }, "image2": { "type": "Invocation", "arguments": { "image1": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "SoilMoi10_40cm_inst" ] }, "functionName": "Image.select" }, "image2": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "SoilMoi0_10cm_inst" ] }, "functionName": "Image.select" } }, "functionName": "Image.add" } }, "functionName": "Image.add" }, "names": [ "sm_root" ] }, "functionName": "Image.rename" }, "geometry": { "type": "Invocation", "arguments": { "tableId": "users/wxw/Study_area_Hebei" }, "functionName": "Collection.loadTable" } }, "functionName": "Image.clip" }, "source": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "properties": [ "system:index", "system:time_start" ] }, "functionName": "Image.copyProperties" } } }, "functionName": "Collection.map" }, "filter": { "type": "Invocation", "arguments": { "start": { "type": "ArgumentRef", "value": "_MAPPING_VAR_2_0" }, "end": { "type": "ArgumentRef", "value": "_MAPPING_VAR_2_0" }, "field": "day_of_year" }, "functionName": "Filter.calendarRange" } }, "functionName": "Collection.filter" } }, "functionName": "reduce.mean" }, "geometry": { "type": "Invocation", "arguments": { "tableId": "users/wxw/Study_area_Hebei" }, "functionName": "Collection.loadTable" } }, "functionName": "Image.clip" }, "key": "system:time_start", "value": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "year": 2011, "month": 1, "day": 1 }, "functionName": "Date.fromYMD" }, "delta": { "type": "Invocation", "arguments": { "left": { "type": "ArgumentRef", "value": "_MAPPING_VAR_2_0" }, "right": 1 }, "functionName": "Number.subtract" }, "unit": "day" }, "functionName": "Date.advance" } }, "functionName": "Element.set" } } }, "functionName": "List.map" } }, "functionName": "List.flatten" } }, "functionName": "ImageCollection.fromImages" }, "filter": { "type": "Invocation", "arguments": { "rightField": "system:time_start", "leftValue": { "type": "Invocation", "arguments": { "start": { "type": "Invocation", "arguments": { "value": "2011-06-09" }, "functionName": "Date" }, "end": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "value": "2011-06-10" }, "functionName": "Date" }, "delta": { "type": "Invocation", "arguments": { "left": 15, "right": 8 }, "functionName": "Number.multiply" }, "unit": "day" }, "functionName": "Date.advance" } }, "functionName": "DateRange" } }, "functionName": "Filter.dateRangeContains" } }, "functionName": "Collection.filter" }, "count": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "images": { "type": "Invocation", "arguments": { "list": { "type": "Invocation", "arguments": { "list": { "type": "Invocation", "arguments": { "start": 1, "end": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "year": 2011, "month": 1, "day": 1 }, "functionName": "Date.fromYMD" }, "delta": 1, "unit": "year" }, "functionName": "Date.advance" }, "start": { "type": "Invocation", "arguments": { "year": 2011, "month": 1, "day": 1 }, "functionName": "Date.fromYMD" }, "unit": "day" }, "functionName": "Date.difference" }, "step": 8 }, "functionName": "List.sequence" }, "baseAlgorithm": { "type": "Function", "argumentNames": [ "_MAPPING_VAR_2_0" ], "body": { "type": "Invocation", "arguments": { "object": { "type": "Invocation", "arguments": { "input": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "id": "NASA/GLDAS/V021/NOAH/G025/T3H" }, "functionName": "ImageCollection.load" }, "filter": { "type": "Invocation", "arguments": { "start": 2011, "end": 2011, "field": "year" }, "functionName": "Filter.calendarRange" } }, "functionName": "Collection.filter" }, "baseAlgorithm": { "type": "Function", "argumentNames": [ "_MAPPING_VAR_0_0" ], "body": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "SoilMoi0_10cm_inst", "SoilMoi10_40cm_inst", "SoilMoi40_100cm_inst" ] }, "functionName": "Image.select" } } }, "functionName": "Collection.map" }, "baseAlgorithm": { "type": "Function", "argumentNames": [ "_MAPPING_VAR_0_0" ], "body": { "type": "Invocation", "arguments": { "destination": { "type": "Invocation", "arguments": { "input": { "type": "Invocation", "arguments": { "input": { "type": "Invocation", "arguments": { "image1": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "SoilMoi40_100cm_inst" ] }, "functionName": "Image.select" }, "image2": { "type": "Invocation", "arguments": { "image1": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "SoilMoi10_40cm_inst" ] }, "functionName": "Image.select" }, "image2": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "SoilMoi0_10cm_inst" ] }, "functionName": "Image.select" } }, "functionName": "Image.add" } }, "functionName": "Image.add" }, "names": [ "sm_root" ] }, "functionName": "Image.rename" }, "geometry": { "type": "Invocation", "arguments": { "tableId": "users/wxw/Study_area_Hebei" }, "functionName": "Collection.loadTable" } }, "functionName": "Image.clip" }, "source": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "properties": [ "system:index", "system:time_start" ] }, "functionName": "Image.copyProperties" } } }, "functionName": "Collection.map" }, "filter": { "type": "Invocation", "arguments": { "start": { "type": "ArgumentRef", "value": "_MAPPING_VAR_2_0" }, "end": { "type": "ArgumentRef", "value": "_MAPPING_VAR_2_0" }, "field": "day_of_year" }, "functionName": "Filter.calendarRange" } }, "functionName": "Collection.filter" } }, "functionName": "reduce.mean" }, "geometry": { "type": "Invocation", "arguments": { "tableId": "users/wxw/Study_area_Hebei" }, "functionName": "Collection.loadTable" } }, "functionName": "Image.clip" }, "key": "system:time_start", "value": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "year": 2011, "month": 1, "day": 1 }, "functionName": "Date.fromYMD" }, "delta": { "type": "Invocation", "arguments": { "left": { "type": "ArgumentRef", "value": "_MAPPING_VAR_2_0" }, "right": 1 }, "functionName": "Number.subtract" }, "unit": "day" }, "functionName": "Date.advance" } }, "functionName": "Element.set" } } }, "functionName": "List.map" } }, "functionName": "List.flatten" } }, "functionName": "ImageCollection.fromImages" }, "filter": { "type": "Invocation", "arguments": { "rightField": "system:time_start", "leftValue": { "type": "Invocation", "arguments": { "start": { "type": "Invocation", "arguments": { "value": "2011-06-09" }, "functionName": "Date" }, "end": { "type": "Invocation", "arguments": { "date": { "type": "Invocation", "arguments": { "value": "2011-06-10" }, "functionName": "Date" }, "delta": { "type": "Invocation", "arguments": { "left": 15, "right": 8 }, "functionName": "Number.multiply" }, "unit": "day" }, "functionName": "Date.advance" } }, "functionName": "DateRange" } }, "functionName": "Filter.dateRangeContains" } }, "functionName": "Collection.filter" } }, "functionName": "Collection.size" } }, "functionName": "Collection.toList" }, "index": 0 }, "functionName": "List.get" }, "property": "system:time_start" }, "functionName": "Element.get" } }, "functionName": "Date" }, "format": "YYYYMMdd" }, "functionName": "Date.format" } }, "functionName": "String.cat"}),怎么修改
最新发布