2

I am very new to ee and am trying to export a collection to my drive, after masking for clouds and clipping to myregion... tried to follow the advice in this answer https://stackoverflow.com/questions/35991403/pip-install-unroll-python-setup-py-egg-info-failed-with-error-code-1 where the col2drive function is imported from geetools. But I seem not to have access to the repo, it doesn't show under my read module. Took me a while to find out because the error said is not a function, and thought I was not creating the object correctly.
So I copied the hardcoded version posted here Export each image from a collection in Google Earth Engine to my own repo and tried to load it from there, did not work. I get again and error saying col2drive is not a function... when I do var exportfunction = tools.col2drive; and print(exportfuncion)... it prints "undefined". So is not loading it, I think.

Then I found this other option Google Earth Engine: Export an entire collection, running it directly from python API. Installed python in my computer (Windows10, 64 bits), and when trying to install geetools it needs a module 'fcntl', which apparently does not exist for Windows... there is a suggestion of using win32api, but then again is for windows32 and the advice says that it is important to understand what fcntl is doing in each case before substituing... In any case I have no idea where can I substitue it. Could someone help, I did try.

Here is my (stitched) code in case is useful

var geometry = /* color: #98ff00 */geometry;

//Add tools to export collection
// load tools from Fito Principe
//var tools = require('users/fitoprincipe/geetools:tools');
var tools = require('users/sulazul/Rep:col2Drive')
// add col2drive function
var exportfunction = tools.col2Drive;
print(exportfunction)

// Load Landsat 8 imagery and filter it  
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
                   .filter(ee.Filter.eq('WRS_PATH', 33))
                   .filter(ee.Filter.eq('WRS_ROW', 41))
                   .set('SENSOR_ID', 'OLI_TIRS')
                   .sort("CLOUD_COVER", false);
var count = collection.size()
print("Coleccion", count)

//some more code here to maskclouds and clip to myregion

// Map the function .
var filtered_1 = filtered.map(maskL8sr);
// export collection to google drive
exportfunction(filtered_1,"Landsat8", {
  scale: 30, 
  region: geometry.getInfo()["coordinates"], 
  type: 'float'
});
2
  • I'll have a look at python geetools for Windows Commented Nov 1, 2018 at 16:47
  • Question for Abhilash Singh Chauhan: Can you explain what is agrimask_2001? Commented Aug 26, 2021 at 10:05

2 Answers 2

6

I am the author of both geetools (Python and JavaScript)

The JavaScript repo is share with anyone can read so it should work, but anyhow you can click here to accept the repo, and then do:

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

// Load Landsat 8 imagery and filter it  
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
          .filter(ee.Filter.eq('WRS_PATH', 33))
          .filter(ee.Filter.eq('WRS_ROW', 41))
          .set('SENSOR_ID', 'OLI_TIRS')
          .sort("CLOUD_COVER", false);
var count = collection.size()
print("Coleccion", count)

//some more code here to maskclouds and clip to myregion

// Map the function .
var filtered_1 = filtered.map(maskL8sr);
// export collection to google drive
batch.Download.ImageCollection.toDrive(filtered_1, 'Landsat8', {
  scale: 30,
  region: geometry.getInfo()["coordinates"] // or geometry.getInfo()
})

Documentation here: https://github.com/fitoprincipe/geetools-code-editor/wiki/Batch#imagecollectiontodrivecollection-folder-options

18
  • Hola Rodrigo. I followed your advice and now I'm getting $name is not defined in this scope, what I'm doing is: // Map the function . var filtered_1 = filtered.map(maskL8sr); var listOfImages = filtered_1.toList(filtered_1.size()); var Image1 = listOfImages.get(0); var Image2 = listOfImages.get(1); var Test = ee.ImageCollection.fromImages([Image1, Image2]); print('Test',Test) batch.Download.ImageCollection.toDrive(Test, 'Landsat8', {name:'Test', scale: 30, region: geometry })
    – Ana
    Commented Nov 1, 2018 at 20:59
  • 1
    get a link and pass it to me (as a comment here) Commented Nov 1, 2018 at 20:59
  • 1
    when I do { var batch = require('users/fitoprincipe/geetools:batch'); batch.Download.ImageCollection.toDrive(Grant_2018_IC_first, 'LLL', { scale: 10 // , // region: geometry.getInfo()["coordinates"] // or geometry.getInfo() }) } I get the error { collection.size is not a function } Commented Feb 12, 2020 at 0:21
  • 1
    Hi @AbhilashSinghChauhan, I changed the link to the documentation, if you see there you'll see that there is a name parameter that you can use to do what you want Commented May 7, 2021 at 12:07
  • 1
    @AbhilashSinghChauhan the images you are trying to export do not have a system:time_start property that defines the image date, but it has a system:index property, you can use it like this: code.earthengine.google.com/1d071cdafffeb3e13f682ab9ae65aac3 Commented May 7, 2021 at 12:42
0

In case of MODIS, you can download the batch of tiles as this


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

var collection = ee.ImageCollection('MODIS/006/MOD13A1')  
                .filterBounds(haryana)
                .filterDate(startDate, endDate)
                .select('NDVI') 
                
var count = collection.size()

var all_tiles = collection.map(function(image) { return image.multiply(0.0001).clip(haryana).mask(agrimask_2001).reproject('EPSG:4326', null, 500); }); 
  

var collectionList = all_tiles.toList(all_tiles.size());
var n = collectionList.size().getInfo();

for (var i = 0; i < n; i++) {
      var listOfImages = all_tiles.toList(all_tiles.size());
      var Tile = listOfImages.get(i);
      var allRasters = ee.ImageCollection.fromImages([Tile]);
      
      batch.Download.ImageCollection.toDrive(allRasters, "MODIS Test Download", 
      {name: 'MODIS_{system:index}',
      scale: 500,
      region: yourAreaOfInterest
      })
}


0

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.