How can I get the exact date the image was captured?

  • 26 April 2024
  • 6 replies
  • 11 views

Hi, I’m using the Rest API and retrieving image from this endpoint: https://services.sentinel-hub.com/api/v1/process Here’s my request example:

url = "https://services.sentinel-hub.com/api/v1/process"

headers = {
  'Accept': '*/*',
  'Content-Type': 'application/json',
  'Authorization': f'Bearer {token["access_token"]}',
  'Origin': 'https://apps.sentinel-hub.com',
  'Connection': 'keep-alive',
  'TE': 'Trailers'
}

res = requests.request("POST", url, headers=headers, data = json.dumps(payload), timeout=10)

What I get in the res.content is an image but I’m also interested in the date it was captured. Is there any way I can get the date it was captured?


6 replies

We usually follow a different route - first using the catalogue API (for the moment best on WFS but very soon a STAC option as well) to gather meta-data about available scenes in the area (including their timestamps), then use process API to retreive the data for that specific timestamp.

There is however a function in the EVALSCRIPT to do what you are after, see this example:
https://docs.sentinel-hub.com/api/latest/#/data/Examples_for_S2L1C?id=true-color-and-metadata-multi-part-response-geotiff-and-json

I used the following evalscript:

//VERSION=3

function setup() {
  return {
    input: ["B02", "B03", "B04"],
    mosaicking: Mosaicking.ORBIT,
    output: { id:"default", bands: 3}
  }
}

function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
  outputMetadata.userData = { "metadata":  JSON.stringify(scenes) }
}

function evaluatePixel(samples) {
  return [ 2.5*samples[0].B04, 2.5*samples[0].B03, 2.5*samples[0].B02 ]
}

and also updated my payload with the following parameters:

"responses": [
            {
                "identifier": "default",
                "format": {
                    "type": "image/tiff"
                }
            },
            {
                "identifier": "userdata",
                "format": {
                    "type": "application/json"
                }
            }
        ]

but still I get the image raw data in the response and no metadata. When I do that change, should I expect the raw data or a json response with metadata and image as well?

I’m able to get the metadata if I use only one response at a time, i.e.

"responses": [
          
            {
                "identifier": "userdata",
                "format": {
                    "type": "application/json"
                }
            }
        ]

Are you using this part?
-H 'accept: application/tar' \

gmilcinski:

owever a function in the EVALSCRIPT

Hi @gmilcinski - is it possible to use the process API with a specific scene ID instead of a timestamp?

No, this is not possible. But you can get exact timestamp from catalogue and use it in the process request.

Reply


Planet Monitoring
Investors

© 2024 Planet Labs PBC. All rights reserved.
| Privacy Policy | California Privacy Notice | California Do Not Sell
Your Privacy Choices | Cookie Notice | Terms of Use