Search code examples
javascriptgoogle-earthgoogle-earth-enginegoogle-earth-studio

A mapped function's arguments cannot be used in client-side operations


I am trying to export Google Earth Engine images to Google drive using Google Earth Studio provided by the platform. There is an official guide to export images as following

// Load a landsat image and select three bands.
var landsat = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_123032_20140515')
  .select(['B4', 'B3', 'B2']);

// Create a geometry representing an export region.
var geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]);

// Export the image, specifying scale and region.
Export.image.toDrive({
  image: landsat,
  description: 'imageToDriveExample',
  scale: 30,
  region: geometry
});

Above code works to export image, But I need to export images of specific coordinates so instead of

var landsat = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_123032_20140515')
      .select(['B4', 'B3', 'B2']);

I am using following code,

var landsat = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR")
var point = ee.Geometry.Point([73.0479, 33.6844]);

code executes successfully but when I try to run the task to complete the process I get following error,

A mapped function's arguments cannot be used in client-side operations

Can someone help me, what am I doing wrong here? Thank you


Solution

  • Couple things. First of all, where do you want to position your point? Because now it's positioned in the Arctic Sea. Second, your code works when I execute it, but as it exports an image with a 1x1 pixel of landsat in the Artic Sea, it's empty.. So you must be looking for something else. Since your landsat shows the area close to Bejing, I changed the ee.Point coordinate to match.

    Do you want to export the landsat values just at this one point? Then try this:

    // Load a landsat image and select three bands.
    var landsat = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_123032_20140515')
      .select(['B4', 'B3', 'B2']);
      
    Map.addLayer(landsat, {}, 'landsat image')
    
    // Create a geometry representing an export region.
    var geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]);
    var point = ee.Geometry.Point([116.5632, 40.2404]);
    
    var LandsatAtPoint = landsat.reduceRegions({
        collection: point, 
        reducer: ee.Reducer.mean(),
        scale: 30 // resolution of the bands is 30m
      })
    print(LandsatAtPoint)
    
    // Export the image, specifying scale and region.
    Export.table.toDrive({
      collection: LandsatAtPoint,
      description: 'imageToDriveExample',
    });
    

    It makes more sense to export the values of an image in a table format, instead of a 1x1 pixel image. Therefore I changed Export.image.toDrive to Export.table.toDrive