I wrote this code using the Earth Engine JavaScript API. The code clips the image collection using variable "table," which is a feature collection of about 12,000 points. I get the length of the image collection and use that number to create a a variable "sequence." I use this variable to create a nested map loop of sorts. I grab a single image and get a list of coordinates from that image. Then for each set of coordinates in the list, I store a bunch of information from that point into a dictionary and create a feature out of it. I need to convert this code to Python, but I am not sure how to convert the lines of code that use the map() function twice ("var getImgCoords and var getMetadata"). The variable "sequence2" changes for each loop, so I thought I could use the iterate() function instead of map().
var TerraClimate = ee.ImageCollection("IDAHO_EPSCOR/TERRACLIMATE"),
var table = ee.FeatureCollection("users/adrianom/CAN_AK_Coordinates")
var SearchArea = table;
var SearchAreaGeom = SearchArea.geometry();
var terraclimate_bounds = TerraClimate.filterBounds(SearchAreaGeom);
// Clip collection to search area, more precisely than filterBounds above.
var icClip = terraclimate_bounds.map(function(img){
var i = img.clip(SearchAreaGeom);
return(i);
});
var icClip_len = icClip.size();
var col_list = icClip.toList(icClip_len);
var sequence = ee.List.sequence(0, icClip_len.subtract(1));
var getImgCoords = sequence.map(function(i){
var img = ee.Image(col_list.get(i));
var coords = img.geometry().coordinates();
var coords_len = coords.size();
var sequence2 = ee.List.sequence(0, coords_len.subtract(1));
var getMetadata = sequence2.map(function(j){
var coor = coords.get(j);
var geom = ee.Geometry.Point(coor);
var reduce = img.reduceRegion(ee.Reducer.mean(), geom, 4638.312116386398);
var dictionary = ee.Dictionary({
x: ee.List(coor).get(0),
y: ee.List(coor).get(1),
Start_Date: ee.Date(img.get('system:time_start')),
End_Date: ee.Date(img.get('system:time_end'))
});
var combine_dict = reduce.combine(dictionary);
var feature = ee.Feature(geom, combine_dict);
return(feature);
});
return(getMetadata);
});