0

I am pretty new to GEE, but somehow find my way to get an imagecollection that I want to export. Then I find geetools:batch with this answer Link.

Objective and Problem: what I want to do is to exporting an imagecollection (60images) automatically if possible. When I follow this geetools:batch methods, my GEE throw me an error stating In users/fitoprincipe/geetools:batch Line 133: collection.toList is not a function.

Here is the code that I executed and the GEE link [https://code.earthengine.google.com/6fe94ef8660e66eceec51e8d98518b77]:

// import 12 points coordinates csv file
var nesttest = ee.FeatureCollection("projects/ee-sihaochen/assets/NESTTEST");

// create bufferPoints function
 function bufferPoints(radius, bounds) {
   return function(pt) {
     pt = ee.Feature(pt);
     return bounds ? pt.buffer(radius).bounds() : pt.buffer(radius);
   };
 }

// create 500m buffers for each point
var roi = nesttest.map(bufferPoints(500, false));
print(roi.size(), "roi size");
print(roi.getInfo());

// feature collection to List
var roigeometrylistfeature = roi.toList(roi.size());
print(roigeometrylistfeature, 'featurecollection to list');
// get first-index item in a list and conver to geometry
var roilist_0 = ee.Feature(roigeometrylistfeature.get(0));
var roilist_0_g = roilist_0.geometry();
print(roilist_0, roilist_0_g);

var start_year = 2016;
var end_year = 2020;
var years = ee.List.sequence(start_year, end_year);

function best_image_each_year (year){
  var start_date = ee.Date.fromYMD(year, 01, 01);
  var end_date = start_date.advance(1, 'year');
  var image = ee.ImageCollection("LANDSAT/LE07/C02/T1_TOA")
              .filterBounds(roilist_0_g)
              .filterDate(start_date, end_date)
              .select(['B3', 'B2', 'B1'])
              .sort("CLOUD_COVER")
              .first()
              .clip(roilist_0_g);
  return image;
}

var roilist_0_g_2016_2020 = years.map(best_image_each_year);
print(roilist_0_g_2016_2020);


//\\ Exporting data
// batch download https://github.com/fitoprincipe/geetools-code-editor/wiki/Batch; https://code.earthengine.google.com/dcee89acbe86bca49ce72605a9f5a7fe;
// https://code.earthengine.google.com/15f748dffa93c031eac646e449981d9d

var batch = require('users/fitoprincipe/geetools:batch');

batch.Download.ImageCollection.toDrive(roilist_0_g_2016_2020, 'Landsat07', {scale: 30});

Does anyone know how to deal with this ..not a function error?

Here is the Link for geetools:batch documentation.

2
  • Welcome to GIS SE. As a new user, please take the Tour, which emphasizes the importance of asking One question per Question. You have a number of question marks here, which makes it difficult to determine the focus of your Question.
    – Vince
    Commented Oct 21, 2022 at 1:37
  • Thanks @Vince, I will take a tour. I guess I have found a solution myself. For those might share a same situation, please make sure convert your filtered images to a image collection. var roilist_0_g_2016_2020_col = ee.FeatureCollection(roilist_0_g_2016_2020);
    – Sihao
    Commented Oct 21, 2022 at 2:58

1 Answer 1

1

toList is a method that exists on collections but not lists. We can reasonably conclude that batch.Download.ImageCollection.toDrive probably wants a collection (it's in the name), but you're passing a list. So, you can convert the list to a collection.

batch.Download.ImageCollection.toDrive(
  ee.ImageCollection(roilist_0_g_2016_2020),
  'Landsat07',
  {scale: 30}
);
1
  • yes!! that's how I did, and now it works! thanks for your answer..
    – Sihao
    Commented Oct 22, 2022 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.