I am mapping over a function that returns images, more specifically changemaps made with the LandTrendr API, which are ee.Images (according to the LandTrendr for GEE homepage).
I end up with a list (see print output in code below) of images and want to use a for-loop to write them to my Google drive. (I am aware that for-loops are deprecated in GEE.)
However, no task is created and no error is thrown, leaving me puzzled to what is wrong/missing.
Here is a reproducible example. If you have not used LandTrendr before and want to run this example you have to visit this site first to add the API to your account.
var years = ee.List.sequence(1985, 1995, 5);
var aoi = ee.Geometry.Point(13.64, 55.9552).buffer(500);
var imageList = years.map(function(n) {
// define landtrendr parameters
var startYear = 1985;
var endYear = 1995;
var startDay = '06-20';
var endDay = '09-10';
var index = 'NDVI';
var maskThese = ['cloud', 'shadow', 'snow', 'water'];
var runParams = {
maxSegments: 6,
spikeThreshold: 0.9,
vertexCountOvershoot: 3,
preventOneYearRecovery: false,
recoveryThreshold: 0.9,
pvalThreshold: 0.05,
bestModelProportion: 0.75,
minObservationsNeeded: 6
};
var strt = ee.Number(n)
var nd = ee.Number(n).add(5)
// define change parameters
var changeParams = {
delta: 'loss',
sort: 'greatest',
year: {checked:true, start: strt, end: nd},
mag: {checked:false, value:100, operator:'>'},
dur: {checked:false, value:5, operator:'<'},
preval: {checked:false, value:300, operator:'>'},
mmu: {checked:false, value:11},
};
// load the LandTrendr.js module
var ltgee = require('users/emaprlab/public:Modules/LandTrendr.js');
// add index to changeParams object
changeParams.index = index;
// run landtrendr
var ftvList = ['NDVI'];
var lt = ltgee.runLT(startYear, endYear, startDay, endDay, aoi, index, ftvList, runParams, maskThese);
// get the change map layers
var changeImg = ltgee.getChangeMap(lt, changeParams);
return changeImg
});
print(imageList) //Output below
//List (3 elements)
//0: Image (6 bands)
//type: Image
//bands: List (6 elements)
//0: "yod", signed int16, EPSG:4326
//1: "mag", double, EPSG:4326
//2: "dur", double, EPSG:4326
//3: "preval", double, EPSG:4326
//4: "rate", double, EPSG:4326
//5: "dsnr", double, EPSG:4326
//1: Image (6 bands)
//2: Image (6 bands)
for (var i = 0; i<imageList.length; i++) {
// get changemap from list
var im = imageList.get(i)
// Export band named 'mag' as GeoTiff
Export.image.toDrive({
image: im.select(['mag']),
description: 'changemap_'+i,
scale: 30,
region: aoi,
fileFormat: 'GeoTIFF',
maxPixels: 3991919404
});
}