How to retrieve ndvi values from 'landsat-mss-l1'

referring to this section:

i want to get ndiv values from the satellite mission: landsat 5 of type landsat-mss-l1
as mentioned in the above posted link, the data availability of it is from 1984 to October 1992, and from June 2012 to January 2013

as mentioned below in the code, i set the following timeRange:
“from”:“2012-06-01T00:00:00Z”,
“to”:“2012-12-31T23:59:59Z”

but then when i post the request, i receive bad request which indicates that there is something wrong with the request sentinel-hub
would you please point out why the below posted request is being rejected?

code:

    return {
        "input": {
            "bounds": {
              "geometry": coordsInEPSG3857,
              "properties": {
                "crs": "http://www.opengis.net/def/crs/EPSG/0/3857"
              }
            },
            "data": [
              {
                "dataFilter": {
                  "timeRange": {
                    "from":"2012-06-01T00:00:00Z",
                    "to":"2012-12-31T23:59:59Z"
                  }
                },
                "type": 'landsat-mss-l1'
              }
            ]
          },
          "output": {
            "width": width,
            "height": height,
            "responses": [
              {
                "identifier": "default",
                "format": {
                  "type": "image/tiff"
                }
            }            
            ]
          },
          "evalscript": `
          function setup() {
              return {
                input: [{
                  bands: ["B04", "B08"],
                  units: "DN"
                }],
                output: {
                  bands: 1,
                  sampleType: SampleType.FLOAT32
                },
                mosaicking: Mosaicking.ORBIT
              }
            }

            function updateOutput(outputs, collection) {
                Object.values(outputs).forEach((output) => {
                    output.bands = collection.scenes.length;
                });
            }
            function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
                var dds = [];
                for (i=0; i<scenes.length; i++){
                  dds.push(scenes[i].date)
                }
                outputMetadata.userData = { "acquisition_dates":  JSON.stringify(dds) }
            }
            
            function evaluatePixel(samples) {
              var n_observations = samples.length;
              let ndvi = new Array(n_observations).fill(0);
              samples.forEach((sample, index) => {
                ndvi[index] = (sample.B08 - sample.B04) / (sample.B08 + sample.B04) ;
              });        
              return ndvi;
            }`
        };
}

Hi,

Please check the bands you are using in your evalscript. Landsat-mss-l1 only has 4 four bands. You can check the bands on the page that you linked in your question. They still include a NIR and Red band but they are not Band 4 and 8 but actually Band 2 and 4.

Hi
thanks
do you mean, that for the evalscript i should replace any B04 with B02, and any B08 with B04?
i want to get the ndvi values!

i thought that the evalscript included in my question is applicable for any satellite as i want to get the ndvi

Hi,

Yes you will need to replace the bands in the evalscript with the corresponding Red and NIR bands for each satellite. Every satellite collects different bands, some are common amongst most sensors like Red and NIR but they will either be named or numbered differently. Therefore, your script should be adjusted depending on the sensor you are obtaining the data from.

i modified the evalscript to look as follows:

"evalscript": `
          function setup() {
              return {
                input: [{
                  bands: ["B02", "B04"],
                  units: "DN"
                }],
                output: {
                  bands: 1,
                  sampleType: SampleType.FLOAT32
                },
                mosaicking: Mosaicking.ORBIT
              }
            }

            function updateOutput(outputs, collection) {
                Object.values(outputs).forEach((output) => {
                    output.bands = collection.scenes.length;
                });
            }
            function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
                var dds = [];
                for (i=0; i<scenes.length; i++){
                  dds.push(scenes[i].date)
                }
                outputMetadata.userData = { "acquisition_dates":  JSON.stringify(dds) }
            }
            
            function evaluatePixel(samples) {
              var n_observations = samples.length;
              let ndvi = new Array(n_observations).fill(0);
              samples.forEach((sample, index) => {
                ndvi[index] = (sample.B04 - sample.B02) / (sample.B04 + sample.B02) ;
              });        
              return ndvi;
            }`

but still i get bad request
how to solve this issue please?

Hi, Please share your full request so I can replicate the issue. I cannot replicate the script above as the coordinates are not provided.

here it is, please check it

request:

"input": {
            "bounds": {
              "geometry": {"type":"Polygon","coordinates":[[[1432804.3786956521,6529218.654819961],[1432232.623454533,6527774.220526608],[1434519.6444190098,6528255.698624392],[1432804.3786956521,6529218.654819961]]]},
              "properties": {
                "crs": "http://www.opengis.net/def/crs/EPSG/0/3857"
              }
            },
            "data": [
              {
                "dataFilter": {
                  "timeRange": {
                    "from": "01-06-2012T" + "00:00:00Z",
                    "to":"12-07-2012T" + "23:59:59Z"
                  }
                },
                "type": 'landsat-mss-l1' 
              }
            ]
          },
          "output": {
            "width": width,
            "height": height,
            "responses": [
              {
                "identifier": "default",
                "format": {
                  "type": "image/tiff"
                }
            }         
            ]
          },
          "evalscript": `
          function setup() {
              return {
                input: [{
                  bands: ["B02", "B04"],
                  units: "DN"
                }],
                output: {
                  bands: 1,
                  sampleType: SampleType.FLOAT32
                },
                mosaicking: Mosaicking.ORBIT
              }
            }

            function updateOutput(outputs, collection) {
                Object.values(outputs).forEach((output) => {
                    output.bands = collection.scenes.length;
                });
            }
            function updateOutputMetadata(scenes, inputMetadata, outputMetadata) {
                var dds = [];
                for (i=0; i<scenes.length; i++){
                  dds.push(scenes[i].date)
                }
                outputMetadata.userData = { "acquisition_dates":  JSON.stringify(dds) }
            }
            
            function evaluatePixel(samples) {
              var n_observations = samples.length;
              let ndvi = new Array(n_observations).fill(0);
              samples.forEach((sample, index) => {
                ndvi[index] = (sample.B04 - sample.B02) / (sample.B04 + sample.B02) ;
              });        
              return ndvi;
            }`
        };

OK, I think the error might be misleading. Are you certain there is a data in the area of interest you have specified and the time range?

there is data here:
{“type”:“Polygon”,“coordinates”:[[[1074273.3971502944,6487761.150518039],[1075663.5956022306,6487266.69849132],[1072704.0494133139,6487073.217263473],[1074273.3971502944,6487761.150518039]]]}

for the above coordinates, i tested it using sentinel-2-l2a and i got a tiff file, but when i use landsat-mss-l1 i get bad-request

Yes, there will be data for Sentinel-2 L2A as this has been collecting data since October 2016. You will not have found data before this though as the satellite was not launched.

I cannot find any Landsat-mss-l1 data for your area of interest in the time range that you specified, can you confirm it is an area of interest near the border of Czechia and Germany?

according to my understanding, as mentioned here
landsat has global data availability, so i expect to have data for the following geometry
{“type”:“Polygon”,“coordinates”:[[[1094289.8066244652,6959734.017600685],[1094036.5232198949,6959250.476555597],[1095011.280564756,6959373.28063054],[1094289.8066244652,6959734.017600685]]]}

am i right please?

To manage expectations, global data availability does not mean there is data available across the whole globe for every single date. Reading further into this on the USGS website documentation it says:

In June 2012, the MSS sensor was powered back on to see if data could be acquired, and the sensor collected nearly 20,000 scenes until January 2013.

Exploring the data in EO Browser, it appears the data in this time period was only collected over the USA.

There are alternative sensors such as Landsat 8/9 that are not part of the data collection you are looking at that you can generate NDVI from. Landsat 8 began operating in 2013 and unfortunately before then the archive is more fragmented, there is Landsat 7 that has been collecting data since 1999, however, all scenes collected since May 30, 2003 have data gaps due to the Scan Line Corrector (SLC) failure. The reality is that the further back in time you go, the less usable data there is that you can use.

Good morning

in the link you provided of EO Browser, it shows that for landsat1-5 there is data for the time period of 2012-04-11 00:00 while in this link it indicates that there is data starting from June 2012 to January 2013
would you please clarify?

We need to look into this as you are right that the data is from April 2012. Once we have found the cause of this we will update you here and in the documentation if required.

Alternatively, you can use Landsat 4-5 TM data. This was the same satellite but a different sensor is used to collect the data. In addition, the resolution is also improved at 30m rather than 60m for the MSS sensor.