Sunday 9 July 2017

google earth engine - Start a loop from information in a feature property


I have a feature collection of polygons that contains a property ("yrbegun") indicating the year I want to use to do some manipulation. I would like to start a loop from the year before to the year after, i.e. if the property indicates 2005, I want to loop from 2004 to 2006


// Determine the year the project was started 
var projectyear = ee.Number(inFeature.get("yrbegun"))

// Define the "boundaries" of the loop

var startyear = projectyear.subtract(1)
var endyear = projectyear.add(1)

// Run the loop
for (var yr= projectyear; yr <= endyear; yr = yr + 1) {

print('This is year ' + yr)
print(yr)

}


However, the loop never runs. I tried to define projectyear without the ee.Number() function, but it also does not work.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...