Friday, 1 April 2016

javascript - Export each image from a collection in Google Earth Engine


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

Answer



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



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...