How to download EODATA file using boto3 on WEkEO Elasticity

Download particular Landsat-5 image.


We strongly recommend using virtualenv for isolating python packages. Configuration tutorial is available here: How to install Python virtualenv or virtualenvwrapper on WEkEO Elasticity.

If virtualenv is activated:

(myvenv) eouser@vm01:~$ pip3 install boto3

Or if we install package globally:

eouser@vm01:~$ sudo pip3 install boto3

Script for downloading one .png file

You will need EODATA access key and secret key to execute the code below. Obtain them by following this article: How to get credentials used for accessing EODATA on a cloud VM on WEkEO Elasticity. In the code below, replace the contents of the access_key variable with your access key and the contents of the secret_key variable with your secret key, respectively.

Remember that you cannot change the output file extension. If you do so, the file content would be empty.

import boto3
access_key='YOUR ACCESS KEY'
secret_key='YOUR SECRET KEY'
aws_secret_access_key=secret_key, endpoint_url=host,)

bucket.download_file(key, '/home/eouser/image.png')

Save your file with .py extension and run with the ‘python3 <>’ command in your terminal. For example:

(boto3) eouser@vm01:~$ python3

And here’s result:

(boto3) eouser@vm01:~$ python3
(boto3) eouser@vm01:~$ ls  image.png