5

I am trying to export each image in a filtered stack of Sentinel-1 images and cannot seem to get it right.

Think link suggests using imageCollection.map() and a custom function (such as a geometric clip).

// Create a geometry representing an export region.
var roi = ee.Geometry.Rectangle([-63.0, 9.2, -63.1, 9.3]);


// Load the Sentinel-1 ImageCollection.
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD');


// Filter by metadata properties.
var IW_H = sentinel1
  // Filter to get images with VV and VH dual polarization.
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
  // Filter to get images collected in interferometric wide swath mode.
  .filter(ee.Filter.eq('instrumentMode', 'IW'))
  // Filter IWs to get High res.
  .filter(ee.Filter.eq('resolution', 'H'))
  // Filter IW-Highs to get 10m res
  .filter(ee.Filter.eq('resolution_meters', 10));


// Filter to get images from different look angles 
var DescCollection = IW_H.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'));


var ClipFunc = function(iImage, geom) {
  var iClip = clip(iImage, geom);
  return(iClip);
};


imageCollection.map(ClipFunc(DescCollection, roi));
9

Export.image.toDrive is a client-side function, and you cannot call it from a server-side function (the one you are mapping over), so you have to do it all in the client side. I have a repo where you can find a bunch of useful functions: https://github.com/fitoprincipe/geetools-code-editor There is a function to export all images from an ImageCollection to the Drive cloud.

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

// Create a geometry representing an export region.
var roi = ee.Geometry.Rectangle([-63.0, 9.2, -63.1, 9.3]);


// Load the Sentinel-1 ImageCollection.
var sentinel1 = ee.ImageCollection('COPERNICUS/S1_GRD');


// Filter by metadata properties.
var IW_H = sentinel1
  // Filter to get images with VV and VH dual polarization.
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
  .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
  // Filter to get images collected in interferometric wide swath mode.
  .filter(ee.Filter.eq('instrumentMode', 'IW'))
  // Filter IWs to get High res.
  .filter(ee.Filter.eq('resolution', 'H'))
  // Filter IW-Highs to get 10m res
  .filter(ee.Filter.eq('resolution_meters', 10));


// Filter to get images from different look angles 
var DescCollection = IW_H.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'));

batch.Download.ImageCollection.toDrive(DescCollection, 'Folder', 
                {scale: 10, 
                 region: roi.getInfo()["coordinates"], 
                 type: 'float'})

You can find the complete code in here and the documentation here

  • Thanks for the response. I've seen this code and attempted it. I'm not very knowledgeable with GEE or javascript. My Chrome browser is going unresponsive and asks to be killed. I'm not sure if it's running (and grinding down my machine) or if something is amiss. I will try with a very limited collection as a test. cheers – ThrushJacket Jul 19 '17 at 21:14
  • @ThrushJacket I use mainly the Python API, so I am not sure if this works properly, I'll check it right now. I think the region parameter may cause the error – Rodrigo E. Principe Jul 19 '17 at 22:08
  • @ThrushJacket I tested it, works fine just as it is. Try with less images, as it is a client side, it can hang your browser. – Rodrigo E. Principe Jul 19 '17 at 22:21
  • 3
    If your export image gets too large GEE will export it in separate shards you can merge after downloading. – Kersten Jul 20 '17 at 12:00
  • 1
    You are importing the repository into tools variable but trying to use batch.. see: code.earthengine.google.com/dcee89acbe86bca49ce72605a9f5a7fe (line 90 makes the difference) – Rodrigo E. Principe Jul 16 at 11:41
0

Despite my efforts,

I was unable to apply Rodrigo E. Principe's algorithm. The GEE states the following phrase:

"Cannot read property 'toDrive' of undefined"

I tried to run the algorithm for two different imageCollections, but the same error occured in both. The first was Rodrigo's Dataset (SENTINEL-1 data), exactly as stated in his answer above. The second trial was over precipitation data. This later algorithm is presented below.

 var batch = require('users/fitoprincipe/geetools:batch');
 var Municipios =  ee.FeatureCollection("ft:1YvIAGUsonY9NVnSJETwkWjj_UO_Db0zqSHx2WHIs");

print(Municipios.limit(20), 'Municipios 500x500m2');


var roi = Municipios.geometry().dissolve().bounds();

print(roi, 'roi');

print(roi.getInfo()["coordinates"], 'get info coordinates from roi');

// Display the sample region.
Map.centerObject(roi, 5);
Map.addLayer(ee.Image().paint(roi, 0, 2), {}, 'ROI');



// Load a pre-computed Landsat composite for input.
var precipitation = ee.ImageCollection('UCSB-CHG/CHIRPS/DAILY')
    .filterDate('1981-01-01', '2019-12-31')
    .select('precipitation')
    .filterBounds(Municipios.geometry().dissolve().bounds())
    .map(function(image) {
      // Data to .
      return image.set('system:time_start', image.get('system:time_start'));
    });

Map.addLayer(precipitation, {'bands': ['precipitation'], min:0, max:2000}, 'collection');




batch.ImageCollection.toDrive(precipitation, 
                'Precipitation_daily_data', 
                {scale: 1000, 
                 maxPixels:5000000000,
                 region: roi.getInfo()["coordinates"], 
                 type: 'float'})

I would like to state that I paid attention to the directory into which the dataset would be downloaded in my Google Drive ('Precipitation_daily_data'), so to garantee beforehand that it would exist, as states in the batch manual cited by Rodrigo.

I thank you for your time,

Sincerely yours,

Philipe R. Leal

  • Apparently, the error appeared due to a misuse of the property Download from the batch object. I am somehow managing to operate the precipitation dataset by replacing "batch.ImageCollection.toDrive" to "batch.Download.ImageCollection.toDrive". – Philipe Riskalla Leal Apr 17 at 13:13
  • sorry Philipe and all who had the same problem. I didn't see this comment before. I've now corrected the answer, you were right about the code. – Rodrigo E. Principe Jul 15 at 13:21

protected by Community Oct 14 '18 at 13:57

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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