1

I want to apply an image visualisation to all the images from a filtered image collection, and export the images to Google Drive using the GEE Javascript API.

I can do the export fine, but I just end up with binary black/white images that aren't useful, so I need to add a {min:-20, max:1} visualisation to each image in the collection either before or during the export job.

Here is the code I'm using to try and achieve that, adapted from the answers to Export each image from a collection in Google Earth Engine.

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

// Define a rectangular image region for filtering the collection and exporting images
var geometry = 
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[-73.85413391074309, -47.41730172316857],
          [-73.85413391074309, -47.47117019964287],
          [-73.72641784628996, -47.47117019964287],
          [-73.72641784628996, -47.41730172316857]]], null, false);

// Load the Sentinel-1 Image Collection and filter by properties          
var IW_H = ee.ImageCollection('COPERNICUS/S1_GRD')
        .filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
        .filter(ee.Filter.eq('instrumentMode', 'IW'))
        .filterBounds(geometry)
        .filterDate('2017-07-01', '2017-07-20')
        .select('VV');

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

// Define visualisation parameters for the exported Sentinel-1 images
var visParams = {min: -20, max: 1};

// Export all images in collection to test folder in my drive
batch.Download.ImageCollection.toDrive(DescCollection.visualize(visParams), 'test', 
                {scale: 10, 
                 region: geometry, 
                 fileFormat: 'GeoTIFF',
                 formatOptions: {
                  cloudOptimized: true
                  }
                });
1

.visualize() is an ee.Image method, so you must map over the collection to apply visualization to each image in the collection before exporting.

Replace your export code chunk with this:

// Map over the collection to convert VV data to vis-gray visualization images.
var DescCollectionVis = DescCollection.map(function(img) {
  return img.visualize(visParams).copyProperties(img, img.propertyNames());
});

// Export all images in collection to test folder in my drive
batch.Download.ImageCollection.toDrive(DescCollectionVis, 'test', 
                {scale: 10, 
                 region: geometry, 
                 fileFormat: 'GeoTIFF',
                 formatOptions: {
                  cloudOptimized: true
                  }
                });

For further reference on mapping a function over a collection, see this developer guide section: https://developers.google.com/earth-engine/getstarted#mapping-what-to-do-instead-of-a-for-loop

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