ALL

Back

How to download EO DATA file using boto3?

Download particular Sentinel-2 image:

Attention!
To use boto3 your virtual machine has to be initialized in project with eo data.
We strongly recommend using virtualenv for isolating python packages.
Configuration tutorial is presented below:
How to install Python virtualenv/virtualenvwrapper?

If virtualenv is activated:

  $ pip install boto3

Or if we install package globally:

  $ sudo pip install boto3

 

Script for downloading one .png file

Remember that you cannot change the output file extension. In the other case the file content would be empty.

import boto3

access_key='anystring'
secret_key='anystring'
key='Landsat-5/TM/L1T/2011/11/11/LS05_RKSE_TM__GTC_1P_20111111T093819_20111111T093847_147313_0191_0025_1E1E/LS05_RKSE_TM__GTC_1P_20111111T093819_20111111T093847_147313_0191_0025_1E1E.BP.PNG'
host='http://data.cloudferro.com'

s3=boto3.resource('s3',aws_access_key_id=access_key,
aws_secret_access_key=secret_key, endpoint_url=host,)

bucket=s3.Bucket('DIAS')

bucket.download_file(key, '/home/eouser/image.png')
Save your file with .py extension and run with the python [filename.py] command in your terminal.