Skip to main content

Hi,

I am trying to know or get a list of the dates of images available for a specific area, previously when I used Sentinel API and selected the area of interest, the files (folders) were downloaded and in them contained the date on which the shots were taken, currently with Sentinel Hub, it allows me to download several requests (TAR file) on the dates that I have indicated, for example from January 01 to January 31, 2018, but I only want to download the images that were taken by the Sentinel 2 satellite during the date I selected (I know that the Sentinel-2 satellite takes every 5 days), additionally I do not know the exact date of each request, i.e., on what date each shot was taken.


My questions are as follows:


Is there any way to download all the available images that exist in the period indicated above?


How do I know which date each shot corresponds to?


I have reviewed some examples, such as the following:


[Where can I get a list of the available imagery dates for a specific area?]

[How can I get all the images from an area of interest in a desired time period?]


Attached is the code I am using:


evalscript_true_color = """
//VERSION=3

function setup() {
return {
input: [{
bands: ["B02", "B03", "B04"]
}],
output: {
bands: 3
}
};
}

function evaluatePixel(sample) {
return [sample.B04, sample.B03, sample.B02];
}
"""
start = datetime.datetime(2018, 1, 1)
end = datetime.datetime(2018, 1, 31)
n_chunks = 31
tdelta = (end - start) / n_chunks
edges = [(start + i * tdelta).date().isoformat() for i in range(n_chunks)]
slots = [(edges[i], edges[i + 1]) for i in range(len(edges) - 1)]

print("Monthly time windows:\n")
for slot in slots:
print(slot)
def get_true_color_request(time_interval, save_data=True):
return SentinelHubRequest(
data_folder=data_folder,
evalscript=evalscript_true_color,
input_data=[
SentinelHubRequest.input_data(
data_collection=DataCollection.SENTINEL2_L1C,
time_interval=time_interval,
mosaicking_order=MosaickingOrder.LEAST_CC,
)
],
responses=[SentinelHubRequest.output_response("default", MimeType.PNG)],
bbox=betsiboka_bbox,
size=betsiboka_size,
config=config,
)
# create a list of requests
list_of_requests = [get_true_color_request(slot) for slot in slots]
list_of_requests = [request.download_list[0] for request in list_of_requests]

# download data with multiple threads
data = SentinelHubDownloadClient(config=config).download(list_of_requests, max_threads=5)

I appreciate any help or suggestions you can provide.

Hi Alejandro,


Your question: How do I know which date each shot corresponds to? is actually more complex to answer than you may initially think with the way the APIs work with requests that are using a time range. This is because it is possible that multiple acquisitions could be used in the returned image from Process API. I’ve put together an example for you to test this out:


curl -X POST https://services.sentinel-hub.com/api/v1/process  -H 'Content-Type: application/json'  -H 'Authorization: Bearer <access_token>'  -d '{   "input": {     "bounds": {       "bbox": :         13.388144,         41.23186,         13.485986,         41.298698       ]     },     "data": :       {         "dataFilter": {           "timeRange": {             "from": "2023-09-22T00:00:00Z",             "to": "2023-09-24T23:59:59Z"           },           "mosaickingOrder": "leastCC"         },         "type": "sentinel-2-l2a"       }     ]   },   "output": {     "width": 631.466,     "height": 573.591,     "responses": :       {         "identifier": "default",         "format": {           "type": "image/jpeg"         }       }     ]   },   "evalscript": "//VERSION=3\n\nfunction setup() {\n  return {\n    input: :\"B02\", \"B03\", \"B04\"],\n    output: { bands: 3 }\n  };\n}\n\nfunction evaluatePixel(sample) {\n  return n2.5 * sample.B04, 2.5 * sample.B03, 2.5 * sample.B02];\n}" }'

This returns:



You can see that this actually returns data from two dates even though the time range is limited to three days. If it is important to you to know the date of the image that you return, I suggest you limit the time range to a single date in your request.


To obtain the dates, you can use Catalog API to obtain these dates. An example of how to make requests for several timestamps using Python can be found here. I think that should help you with what you are trying to achieve 🙂


If you are still stuck, then please reach out to us!


Reply