Google Earth Engine – Suppressing User Updates During geemap.ee_export_image

exportgeemapgoogle-earth-enginegoogle-earth-engine-python-api

I am exporting GEE files to my local machine through the geemap Python API using the following code:

# download 30m SRTM data
SRTM30 = ee.Image('USGS/SRTMGL1_003');
filename = os.path.join(OUTpath, 'DEM_'+domain+'.tif');
geemap.ee_export_image(SRTM30, filename=filename, scale=sm_resolution, region=my_domain, crs = epsg_code);

The geemap.ee_export_image function outputs the following user updates each time it exports an image:

enter image description here

I am exporting a large number of files so I am wondering if there is a way to suppress these user updates so my cron job confirmation email is not so long.

Best Answer

Not directly. You could submit a ticket asking for a verbose parameter to be added to the function.

As a workaround, you could redirect sys.stdout temporarily:

import contextlib
# etc...
with contextlib.redirect_stdout(None):
    geemap.ee_export_image(SRTM30, filename=filename, scale=sm_resolution, region=my_domain, crs = epsg_code)

Or if you are going to use geemap.ee_export_image more than once in your script, you could wrap it into a function

import contextlib
# etc...

def ee_export_image(*args, **kwargs):
    with contextlib.redirect_stdout(None):
        geemap.ee_export_image(*args, **kwargs)

# etc...

ee_export_image(SRTM30, filename=filename, scale=sm_resolution, region=my_domain, crs = epsg_code)