1

I am exporting an image from google earth engine and I want the export file name to be a string I created and concatenate the image metaData (date) with it.

var date = image.get('system:index');
var file_name = ee.String('Area').cat(date);

Export.image.toDrive({
        image: B11,
        description: file_name,
        region: study_area,
        scale: 30,
        maxPixels: 1e8
    });

But in the export tab the file name changes to something like this

ee.String({ "type": "Invocation", "arguments": { "string1": "1495_B4", "string2": { "type": "Invocation", "arguments": { "input": { "type": "Invocation", "arguments": { "object": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "id": "COPERNICUS/S2_SR_HARMONIZED" }, "functionName": "ImageCollection.load" }, "filter": { "type": "Invocation", "arguments": { "leftField": ".all", "rightValue": { "type": "Invocation", "arguments": { "geometry": { "type": "Invocation", "arguments": { "collection": { "type": "Invocation", "arguments": { "tableId": "users/muddasir_assets_workshop/1461" }, "functionName": "Collection.loadTable" } }, "functionName": "Collection.geometry" } }, "functionName": "Feature" } }, "functionName": "Filter.intersects" } }, "functionName": "Collection.filter" }, "filter": { "type": "Invocation", "arguments": { "rightField": "system:time_start", "leftValue": { "type": "Invocation", "arguments": { "start": "2022-07-14", "end": "2022-08-11" }, "functionName": "DateRange" } }, "functionName": "Filter.dateRangeContains" } }, "functionName": "Collection.filter" }, "filter": { "type": "Invocation", "arguments": { "leftField": "CLOUDY_PIXEL_PERCENTAGE", "rightValue": 10 }, "functionName": "Filter.lessThan" } }, "functionName": "Collection.filter" }, "baseAlgorithm": { "type": "Function", "argumentNames": [ "_MAPPING_VAR_0_0" ], "body": { "type": "Invocation", "arguments": { "input": { "type": "ArgumentRef", "value": "_MAPPING_VAR_0_0" }, "bandSelectors": [ "B3", "B4", "B5", "B8", "B11" ] }, "functionName": "Image.select" } } }, "functionName": "Collection.map" } }, "functionName": "Collection.first" }, "property": "system:index" }, "functionName": "Element.get" } }, "functionName": "String" } }, "functionName": "String.cat"})

1 Answer 1

3

This is a classic issue of working with client and server side objects. The problem here is that Export.image.toDrive expects a client side string in the description of the image; however, you are providing a server side string (ee.String). An easy way to convert it to a client side string is using getInfo(). This should do the trick.

Export.image.toDrive({
        image: B11,
        description: file_name.getInfo(),
        region: study_area,
        scale: 30,
        maxPixels: 1e8
    });
1
  • Thank you Jonathan, it worked :)
    – user173819
    Aug 14, 2022 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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