10

My goal is to store different exports from Earth Engine projects in separate subfolders of a main GEE_export folder on my Google Drive. I'm using Export.image.toDrive:

Export.image.toDrive({
    image: export_img,
    folder: export_path,
    fileNamePrefix: filename,
});

However, if I pass a path like GEE_export/subdir or GEE_export\subdir or even GEE_export\\subdir it just creates a folder with a corresponding name in my Drive root folder.

What is wrong?

  • 1
    Same mistake for me. There is no documentation on the web about this. Very uncomfortable. Does anyone have a solution to solve this issue ? Thibault – Interceptor Feb 27 at 9:25
-1

I share an example script from my repository, which should give you some inspiration as to how you can automate/concatenate the file/folder naming process. In this example, I have 3 images and 10 regions, and my objective is to do the following; clip each image to each of the 10 regions, reclassify them and export them to Google Drive.

Hopefully you can understand it, and adapt it for your purposes. Specifically, you can take direction from my code and modify your script in the export parameters:'folder'. Feel free to post your code here so the community can view/reproduce/comment on it.

As a closing note, when you are exporting images from GEE, you should always specify the arguments 'region' and 'scale'. In some cases, if you do not specify, region, the export's extent will default to the extent in your view-port (i.e. the map viewer in GEE code editor).

Disclaimer: there may be many other methods to achieve your goals that are superior to mine, but this is the only one that I know of at the moment. Hope this helps.

Warmest regards,

J Johanness

//  Load vector boundary
var boundary = ee.FeatureCollection('XXX');

//  Define start and end value for vector layer attribute 'name-of-attribute'
var start_region = 1;
var end_region = 10; // E.g. if my ee.FeatureCollection only has 10 features

//  Load images
var image0 = ee.Image('XXX');
var image1 = ee.Image('XXX');
var image2 = ee.Image('XXX');

//  Prepare image reclassification codes
var oldgroup = ee.List([0,10,11,12,20,21,22]);
var newgroup = ee.List([0,0,1,1,0,1,1]);

//  Perform 'loop' operation
var i;
  for (i=0;i<=2;i++){
    //  This creates an image stack
    var imagestack = ee.List([image1,image2,image3]);
    var year_dict = ee.Dictionary({
      '0':'image1',
      '1':'image2',
      '2':'image3'
    });
    var year_string = year_dict.get(ee.Number(i).format()).getInfo();
var j;
  for (j=start_region;j<=end_region;j++){
    var region = boundary.filter(ee.Filter.eq('name-of-attribute', j));
    var imagexregion = ee.Image(imagestack.get(i))
    .clip(region).remap(oldgroup,newgroup);
    var region_string = String(j);
Export.image.toDrive({
  image:imagexregion.uint8(),
  description:'esa-'+region_string+'-'+year_string, // This is the part you are asking about.
  folder:'esa-loop-test',
  region:region,
  scale:300, // spatial resolution of my dataset
  crs:'EPSG:4326',
  maxPixels:1e13,
  fileFormat:'GeoTIFF'});
  }
}
| improve this answer | |

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.