sentinel-hub / sentinelhub-py

Download and process satellite imagery in Python using Sentinel Hub services.
http://sentinelhub-py.readthedocs.io/en/latest/
MIT License
798 stars 243 forks source link

Download as SAFE format #501

Closed anikfal closed 8 months ago

anikfal commented 8 months ago

search_iterator in the code below finds two sentinel2 files as SAFE format (S2A_MSIL2A_20231114T110311_N0509_R094_T31UDQ_20231114T143858.SAFE and S2A_MSIL2A_20231114T110311_N0509_R094_T31UDR_20231114T143858.SAFE):

import os
import datetime
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import requests
import getpass

from sentinelhub import (
    SHConfig,
    DataCollection,
    SentinelHubCatalog,
    SentinelHubRequest,
    BBox,
    bbox_to_dimensions,
    CRS,
    MimeType,
    Geometry,
    MosaickingOrder,
)

config = SHConfig("sebalprofile")
aoi_coords_wgs84 = [2, 49, 2.5, 49.7]
resolution = 10
aoi_bbox = BBox(bbox=aoi_coords_wgs84, crs=CRS.WGS84)
aoi_size = bbox_to_dimensions(aoi_bbox, resolution=resolution)

print(f"Image shape at {resolution} m resolution: {aoi_size} pixels")
catalog = SentinelHubCatalog(config=config)

time_interval = "2023-11-14", "2023-11-14"
search_iterator = catalog.search(
    DataCollection.SENTINEL2_L2A,
    bbox=aoi_bbox,
    time=time_interval,
    fields={"include": ["id", "properties.datetime"], "exclude": []},
)

How can I simply download these two files to my disk?

mlubej commented 8 months ago

Hi @anikfal!

Since you now have the ID of the two products, you can do the following:

  1. Go to the Copernicus Data Space Ecosystems page: https://dataspace.copernicus.eu/
  2. Log in or Register
  3. Go to Explore Data -> Copernicus Browser
  4. Click on the Search tab and enter the product ID (without the extension) in the Search Criteria
  5. Download found product
  6. Repeat for other products

Let me know if you experience any issues with the above

Regards, Matic

anikfal commented 8 months ago

Hi @mlubej

Thanks for your reply. However, this is a code-only issue, without using the GUI. I am still on it and trying to handle it.

mlubej commented 8 months ago

For programmatic access you can take a look at the instructions here: https://dataspace.copernicus.eu/news/2023-9-28-accessing-sentinel-mission-data-new-copernicus-data-space-ecosystem-apis

There is also an example notebook showing how to download the zipped product using OData: https://github.com/eu-cdse/notebook-samples/blob/c0e0ade601973c5d4e4bf66a13c0b76ebb099805/sentinelhub/migration_from_scihub_guide.ipynb