Avoid Downloading image if no Image available

I am trying to download an Sentinel image for a specific date and it returns a black image

I need to add a check in the SentinelHubRequest to avoid downloading the black image if there is no image on that date

below is my python script

evalscript = “”"

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

function evaluatePixel(sample) {
return [2.5 * sample.B04, 2.5 * sample.B03, 2.5 * sample.B02];
bbox = BBox(bbox=[31.460209, 22.820775, 31.547461, 22.893513], crs=CRS.WGS84)

request = SentinelHubRequest(
data_folder= “…/pythonScripts/SentinelImages/”,
time_interval=(‘2021-01-16’, ‘2021-01-16’),
SentinelHubRequest.output_response(‘default’, MimeType.TIFF),

size=[512, 463.08],
response = request.get_data(save_data=True)

Hi @rasha.elkheshin,

You’re receiving a black image because there’s indeed no data available on 16th of January. The closest acquisition of data is 15th January. You may want to check the data availability before requesting.

However, the Sentinel Hub Python package does not have a function to check data availability before requesting.

In your situation, we recommend using Catalog API to search available data on any time period. The Catalog API can be run with Python and it also supports users to search with GeoJSON.

Alternatively, the data availability can be checked via the green marks on the calendar or the catalog API tab in our Requests Builder, or through the EO Browser.


1 Like

Hi @chung.horng

Thanks for your kind reply

I actually managed to use distinct date curl request and made a check if the returned is zero then will not call the SentinelHubRequest function in python

this link helped me with a walk around

import requests

headers = {
‘Content-Type’: ‘application/json’,
‘Authorization’: 'Bearer '+ accessToken,

data = ‘{ “collections”: [ “sentinel-2-l2a” ], “datetime”: “2021-01-16T00:00:00Z/2021-01-16T23:59:59Z”, “bbox”: [ 31.460209, 22.820775, 31.547461, 22.893513 ], “limit”: 100, “distinct”: “date” }’

response = requests.post(‘https://services.sentinel-hub.com/api/v1/catalog/search’, headers=headers, data=data)


1 Like