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 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

  • 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 Nov 1 '18 at 20:59
  • 1
    get a link and pass it to me (as a comment here) – Rodrigo E. Principe Nov 1 '18 at 20:59
  • Thanks a lot for sharing your work and time! It is working now!... don't have enough points to vote, but really grateful. – Ana Nov 2 '18 at 1:16
  • It's fine! glad to help =) – Rodrigo E. Principe Nov 2 '18 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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