1024programmer Java Export all images in the Google Earth Engine image collection (Google Earth Engine API)

Export all images in the Google Earth Engine image collection (Google Earth Engine API)

I need to download a bunch of Landsat images for my thesis. My problem seems simple but I have no clue about Javascript and the documentation is not helpful. I have filtered the collection to my region and time period and I Want to export all images to Drive individually. Collection example:

var surfaceReflectanceL5 = ee.ImageCollection('LANDSAT/LT5_SR');
 var dateSR5=surfaceReflectanceL5.filterDate('1984-01-01', '1985-01-01');
 var prSR5=dateSR5.filter(ee.Filter.eq('wrs_path', 182))
                      .filter(ee.Filter.eq('wrs_row', 35));

The code to export a single image is:

   image: image1 //example, var image1='Landsat/....'
   description: 'L51984_1',
   scale: 30,

How can I loop through a collection to export all images? The use of the map() function seems to be the answer.

   image: image,
   description: 'L51984',
   scale: 30,

Now the question is how to set the image parameters to the correct image (i.e. image number 1, then 2nd etc., like “thisImage()“) and the description to match the image (i.e. 'L51984_1','L51984_2'…).

Thanks in advance!!!

1> Rodrigo E. P..:

I created a function that does something similar. It works Used in a series of gee tools I created: https://github.com/fitoprincipe/geetools-code-editor

This is the code:

  * Author: Rodrigo E. Principe
  * License: Apache 2.0

 This function Exports all images from one Collection
 col = collection that contains the images (ImageCollection) (not optional)
 folder = the folder where images will go (str) (not optional)
 scale = the pixel's scale (int) (optional) (defaults to 1000) (for Landsat use 30)
 type = data type of the exported image (str) (option: "float", "byte", "int", "double") (optional) (defaults to "float")
 nimg = number of images of the collection (can be greater than the actual number) (int) (optional) (defaults to 500)
 maxPixels = max number of pixels to include in the image (int) (optional) (defults to 1e10)
 region = the region where images are on (Geometry.LinearRing or Geometry.Polygon) (optional) (defaults to the image footprint)
 Be careful with the region parameter. If the collection has images
 in different regions I suggest not to set that parameter
 ExportCol(myLandsatCol, "Landsat_imgs", 30)

 var ExportCol = function(col, folder, scale, type,
                          nimg, maxPixels, region) {
     type = type || "float";
     nimg = nimg || 500;
     scale = scale || 1000;
     maxPixels = maxPixels || 1e10;

     var colList = col.toList(nimg);
     var n = colList.size().getInfo();

     for (var i = 0; i <n; i++) {
       var img = ee.Image(colList.get(i));
       var id = img.id().getInfo();
       region = region || img.geometry().bounds().getInfo()["coordinates"];

       var imgtype = {"float":img.toFloat(),

         description: id,
         folder: folder,
         fileNamePrefix: id,
         region: region,
         scale: scale,
         maxPixels: maxPixels})

I haven’t tried many, but I did a few tests, for example:

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

 var col = ee.ImageCollection("LEDAPS/LE7_L1T_SR").filterDate("2002-01-01","2002-01-03");
 batch.Download.ImageCollection.toDrive(col, "Folder", {scale:30});

If you have any questions, you can leave a comment here or publish it on github.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/764815

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

The latest and most comprehensive programming knowledge, all in 1024programmer.com

© 2023 1024programmer - Encyclopedia of Programming Field
Contact Us

Contact us


Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us