How to download L1C images of ".SAFE" format

Hello,
Now, I’m trying to download L1C images of “.SAFE format” with sentinelhub-py 2.4.1.
I put “safe_format” option to “True”, but the downloaded file is same as the case of non options, and the directory constitution is really different from the before. The new directory constitution is similar with the constitution of XXX.SAFE/GRANULE.

What should I do for getting the “.SAFE” format as before?

  • Should I put all of files with “metadata” option?
    Although I put some files with the list of allowable values, they doesn’t work. (I got the list from error message.)

Hi @h-ochi,

if you download a tile with AwsTileRequest into .SAFE format it will create only the part of the .SAFE structure which corresponds with XXX.SAFE/GRANULE. In order to get entire .SAFE structure you have to first obtain a product ID of your tile and then download with AwsProductRequest. Example:

from sentinelhub import AwsProductRequest, AwsTile, DataSource

product_id = AwsTile(tile_name='T38LPH', time='2017-12-15', aws_index=0, data_source=DataSource.SENTINEL2_L1C).get_product_id()

request = AwsProductRequest(product_id=product_id, data_folder='./myFolder', safe_format=True)
data = request.get_data(save_data=True)

I hope this helps. If not please post here your code and error stack trace and we will be able to help you further.
Also please check the examples in documentation.

Hi @maleksandrov,
Thank you for your advice!
Yes, as you told, I tried to download with “AwsTileRequest” as below.
‘’’
tile_request = AwsTileRequest(tile=tile_name,
time=date,
metafiles = self.metafiles,
data_source=DataSource.SENTINEL2_L1C,
data_folder=self.download_image_path,
safe_format=True)
tile_request.get_data(save_data=True)
‘’’
I thought “safe_format” option can also use in “AwsTileRequest”.
I repaired my code:
‘’’
product_id = AwsTile(tile_name=tile_name, time=str(self._date), aws_index=0, data_source=DataSource.SENTINEL2_L1C).get_product_id()
request = AwsProductRequest(product_id=product_id, data_folder=self.download_image_path, safe_format=True)
data = request.get_data(save_data=True)
‘’’

So, now I could get “.SAFE” format with “AwsProductRequest”, but many warning messages are output as below:
‘’’
WARNING in tgt_create tree->numnodes == 0, no tree created.
WARNING: No incltree created.
‘’’
Do you know why? Can I suppress the message?

These warnings are from OpenJpeg system library which is used by Pillow package which is used by sentinelhub for reading Jpeg2000 files.

Basically there are two options:

  • If you only want to download the data and not analyze images in Python I recommend replacing line
    data = request.get_data(save_data=True) with request.save_data(). This will only save downloaded data on your disk and won’t read the images. Hence it won’t raise these warnings and will also work faster.

  • If you plan to further process downloaded images in Python you will have to read the images. In that case I recommend upgrading sentinelhub package to (latest) version 2.4.2 as there have been some fixes about reading Jpeg2000 images. You will still get the same warnings and I am not sure how to suppress them. However the data from images should be read correctly.

Thank you @maleksandrov !
Because I need to further process downloaded images, I updated sentinelhub package to 2.4.2.
So I succeeded to download images and further process!