Skip to main content

How to get the date of RGB image from L8 satellite?

  • April 26, 2024
  • 3 replies
  • 135 views

I have the following payload which I’m trying on L8 API :

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

   payload = {
                "input": {
                    "bounds": {
                        "properties": {
                            "crs": "http://www.opengis.net/def/crs/EPSG/0/32719"
                        },
                        "bbox": bbox_rgb
                    },
                    "data": [
                        {
                            "type": RGB_TYPE,
                            "dataFilter": {
                                "timeRange": {
                                    "from":strt_dt,
                                    "to":end_dt
                                }
                            }
                        }
                    ]
                },
                "output":{"resx":10,"resy":10,
                "responses":[{
                    "identifier": identifier,
                    "format":{"type":"image/jpeg"}
                }]}, 
                # "output":{"width":1000,"height":940},
                "evalscript": evalscript
            }


eval_script_rgb = """
//VERSION=3




let minVal = 0.0;
let maxVal = 0.4;
let viz = new HighlightCompressVisualizer(minVal, maxVal);
function evaluatePixel(samples) {
     let sudoPanW = (samples.B04 + samples.B03 + samples.B02 * 0.4) / 2.4;
     let ratioW = samples.B08 / sudoPanW;
     let val = [samples.B04 * ratioW, samples.B03 * ratioW, samples.B02 * ratioW];
     val = viz.processList(val);
     val.push(samples.dataMask); 
     return val;
}
function setup() {
     return {
          input: [{
               bands: ["B02","B03","B04","B08","dataMask" ]
          }], 
          output: { 
               bands: 4
          }
     }
}




"""

I can download the image but I want to know the exact date when the image was available. Is there any method to do this using the API?

3 replies

Hello,

You can use the outputMetadata to return information about the scene that you are requesting/downloading. In the documentation there are links to examples on how to implement the function.

Maxim


I have tried that and I get the following response:

{"metadata":"[{"idx":0,"bandBuffers":[{},{},{},{},{}]}]"}

However, previously I used to get the date here when using the same script for Sentinel 2. Here is the evalscript for that:

eval_script_rgb_json = """
//VERSION=3




let minVal = 0.0;
let maxVal = 0.4;
let viz = new HighlightCompressVisualizer(minVal, maxVal);
function evaluatePixel(samples) {
     let sudoPanW = (samples.B04 + samples.B03 + samples.B02 * 0.4) / 2.4;
     let ratioW = samples.B08 / sudoPanW;
     let val = [samples.B04 * ratioW, samples.B03 * ratioW, samples.B02 * ratioW];
     val = viz.processList(val);
     val.push(samples.dataMask); 
     return val;
}
function setup() {
     return {
          input: [{
               bands: ["B02","B03","B04","B08","dataMask" ]
          }], 
          output: { 
               bands: 4
          }
     }
}


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

"""

Perhaps this example is most similar. It is for sentinel-2, but you can do the same for L8

docs.sentinel-hub.com
d3714e73b38a87afa3c31502a6696052a7395163.png

Examples for S2L1C

Use these CURL and Postman examples to access Sentinel-2 L1C data with Sentinel Hub Processing API.