Exist image or not

Good morning,

I want to ask how can I check if image exist or not before download it using script of python. (Because everytime I download image and image isn’t exist it is download in black so I need to know first if exist before download it to not have black image).

Also I want to know if it is posible to know if exist collection with same name and coordinate to not create another one with same name and coordinate.

Regards,
Antonio
trueColor.tiff (3.1 KB)
GNDVI.tiff (768.1 KB)

Good morning Antonio,

To check if an image exists or not before running your request, you can make use of our Catalog API. There is also an implementation in Python, since you are already scripting in Python: see the examples in the documentation.

I have problem that i can download image manually using library of python but I can’t using request.save_data(). It is happen to me just in true color in 05/09/2022, just in this date.

Hi Antonio,

Can you provide the code of your request please, so that we can identify the issue?

curl -X POST https://services.sentinel-hub.com/api/v1/process
-H ‘Content-Type: application/json’
-H ‘Authorization: Bearer <YOUR_TOKEN_HERE>’
-d '{
“input”: {
“bounds”: {
“bbox”: [-5.7585989, 37.3886755, -5.7565442, 37.3910112],
“geometry”: {
“type”: “Polygon”,
“coordinates”: [
[
[-5.7580946,37.3905082],
[-5.7579981,37.3903292],
[-5.7585989,37.3902355],
[-5.7585453,37.3893489],
[-5.7583629,37.3886755],
[-5.7573811,37.3887778],
[-5.7565442,37.3910112],
[-5.7580946,37.3905082]
]
]

},
"data": [
  {
    "dataFilter": {
      "timeRange": {
        "from": "2022-10-02T00:00:00Z",
        "to": "2022-11-02T23:59:59Z"
      }
    },
    "type": ""
  }
]

},
“output”: {
“width”: 512,
“height”: 343.697,
“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 [2.5 * sample.B04, 2.5 * sample.B03, 2.5 * sample.B02];\n}”
}’

Could you please help me better understand what issue you are running into? I ran your CURL request above and got an image back. You referred to the Python package in your previous post: does this mean that your CURL request runs but you cannot get the images with Python? If so, do you have the Python code you are using?

I get the image in my collection “My PlanetScope 8-band data” at 05/09/2022 in white. The problem just in day 05/09/2022 that I get it white using planetScope in python and also using request builder.
I want to know the reason why please. (The rest of other days I get the image correctly). I upload the img is in white.

image

Thanks.

Thanks for the clarification, it was not clear to me that you were talking about Planet Scope. After looking: it seems there were no acquisitions on the 5th September 2022. Hence why you don’t get data.

Hi Maxim,

To follow up on Antonio’s question:

  • Are processing units and requests spent when downloading an empty image on a day with no acquisition?
  • If yes, how can we check that there is an image available during the requested time-interval, and if not, not do anything?
  • If there is a processing involved (like removing clouds from an image), would I save some PU if I only download the request result in cases where I have some non-cloudy pixels in my region of interest?

I am working with Sentinel-2 catalogue in Greenland and I am wondering how much PU/requests I am losing when asking for a scene in a region with polar night.

Thanks!

Hi Baptiste,

Are processing units and requests spent when downloading an empty image on a day with no acquisition?

Yes, you spend PUs even if you return an empty image. You can check the PUs consumed in the header of your response.

If yes, how can we check that there is an image available during the requested time-interval, and if not, not do anything?

I would suggest you take a look at our catalog API (documentation, and in the Python package) which you can call in a previous step to filter dates with acquisitions.

I am not familiar with your workflow, but you could also filter out dates without acquisitions directly in your Evalscript based on the dataMask band.

If there is a processing involved (like removing clouds from an image), would I save some PU if I only download the request result in cases where I have some non-cloudy pixels in my region of interest?

Here is a guide on how PUs are calculated: https://docs.sentinel-hub.com/api/latest/api/overview/processing-unit/. This may help you in reducing your consumption.

Furthermore, there are some tips to reduce PUs (based on the SampleType returned) in this blog post.

1 Like