0

While batch downloading the rasters from GEE

I want to pass the year, which are there in the properties of feature

rasters

so that it can name the output dynamically instead of numeric ID's i.e. the name should be Level_2_Monthly_NDVI_LANDSAT_September_2017 instead of Level_2_Monthly_NDVI_LANDSAT_September_1.

enter image description here

var colList = all_out_raster_tiles.toList(all_out_raster_tiles.size());
print("All tiles Collection List ", colList)
var n = colList.size().getInfo();
print("No of tiles in Collection", n)

for (var i = 0; i < n; i++) {
      
      var img = ee.Image(colList.get(i));
      var id = img.id().getInfo();
      var listOfImages = all_out_raster_tiles.toList(all_out_raster_tiles.size());
      var Tile = listOfImages.get(i);
      var allRasters = ee.ImageCollection.fromImages([Tile]);
      print("Raster no " + i, allRasters)
      //var year_name = ee.Number.parse(allRasters.get('year'));
      //print(year_name);

      batch.Download.ImageCollection.toDrive(allRasters, "USAKA_LANDSAT8_NDVI", 
      {name: 'Level_2_Monthly_NDVI_LANDSAT_September_'+id,
      scale: 30,
      region: roi
      })
}
Raster no 2
ImageCollection (1 element)
type: ImageCollection
bands: []
features: List (1 element)
0: Image (1 band)
type: Image
bands: List (1 element)
0: "NDVI", float ∈ [-1, 1], EPSG:4326
properties: Object (4 properties)
month: 9
system:index: 2
system:time_start: 1504224000000
year: 2017

How to do so?

0 Answers0