Too much low values in NDVI computation

Hi, here my requesto to Sentinel2 data to compute NDVI index of a orchard:

{
    "input": {
        "bounds": {
            "properties": {
                "crs": "http: //www.opengis.net/def/crs/OGC/1.3/CRS84"
            },
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [
                        [
                            42.5979522,
                            14.0531316
                        ],
                        [
                            42.5975337,
                            14.0527615
                        ],
                        [
                            42.5971664,
                            14.0524825
                        ],
                        [
                            42.5970045,
                            14.0520426
                        ],
                        [
                            42.5967241,
                            14.0516939
                        ],
                        [
                            42.5965385,
                            14.0514096
                        ],
                        [
                            42.596428,
                            14.0511199
                        ],
                        [
                            42.5961555,
                            14.0512433
                        ],
                        [
                            42.595729,
                            14.0518388
                        ],
                        [
                            42.5954841,
                            14.052504
                        ],
                        [
                            42.5954881,
                            14.0527507
                        ],
                        [
                            42.5952709,
                            14.0526917
                        ],
                        [
                            42.5949431,
                            14.0534535
                        ],
                        [
                            42.5949866,
                            14.0537217
                        ],
                        [
                            42.5951761,
                            14.0540275
                        ],
                        [
                            42.5951761,
                            14.0541723
                        ],
                        [
                            42.5951722,
                            14.0543654
                        ],
                        [
                            42.5954526,
                            14.0545264
                        ],
                        [
                            42.5955394,
                            14.054462
                        ],
                        [
                            42.5957211,
                            14.054403
                        ],
                        [
                            42.5958435,
                            14.0541294
                        ],
                        [
                            42.5960449,
                            14.054285
                        ],
                        [
                            42.5958277,
                            14.0548107
                        ],
                        [
                            42.5957171,
                            14.0548643
                        ],
                        [
                            42.595575,
                            14.054934
                        ],
                        [
                            42.5953459,
                            14.0553149
                        ],
                        [
                            42.5951169,
                            14.0557548
                        ],
                        [
                            42.595342,
                            14.056361
                        ],
                        [
                            42.5955987,
                            14.0569403
                        ],
                        [
                            42.5956934,
                            14.0570637
                        ],
                        [
                            42.595883,
                            14.0569993
                        ],
                        [
                            42.5963845,
                            14.0565541
                        ],
                        [
                            42.5960489,
                            14.0562215
                        ],
                        [
                            42.5967557,
                            14.054875
                        ],
                        [
                            42.5965938,
                            14.054757
                        ],
                        [
                            42.5967992,
                            14.0543225
                        ],
                        [
                            42.5973441,
                            14.0547463
                        ],
                        [
                            42.5979522,
                            14.0531316
                        ]
                    ]
                ]
            }
        },
        "data": [
            {
                "type": "sentinel-2-l2a",
                "dataFilter": {
                    "timeRange": {
                        "from": "2023-06-03T00:00:00Z",
                        "to": "2023-06-06T23:59:59Z"
                    }
                }
            }
        ]
    },
    "output": {
        "width": 4,
        "height": 4,
        "responses": [
            {
                "identifier": "default",
                "format": {
                    "type": "image/tiff"
                }
            }
        ]
    },
    "evalscript": "function setup() {\n        return {\n            input: [{\n            bands: [\n                "B04",\n                "B08",\n                "dataMask"\n            ]\n            }],\n            output: {\n                bands: 1,\n                sampleType: SampleType.FLOAT32\n            }\n        }\n        }\n\n        function evaluatePixel(samples) {\n            let val = (samples.B08-samples.B04)/(samples.B08+samples.B04)\n            //index(samples.B08, samples.B04);\n            //val = Math.round((val+1)*127.5)\n            return [val];\n        }"
}

The code works, but I don’t know how to interpretate the data retrived:
(I used 4x4 pic size in order to make considerations easier)
[[[0.02797203 0.01792115 nan nan]
[0.01796407 0.0263789 0.02612827 0.02040816]
[0.02508961 0.01405152 0.01538462 0.02060606]
[0.01492537 0.01750292 0.0212766 nan]]]
I expect data from -1 to 1, but more precisely between 0 and 0.5-0.6

Can someone help me to understand how to interpretate these results or can tell me if there are any mistake?

Hi Davide,

Checking your AOI, I think it is incorrect. Assuming it is WGS84 it is located off the coast of Oman. In addition, for the shape and size of your AOI, I do not understand why you would only want to output 4x4 pixels. This will always produce unexpected results as the size of the pixels will mean there is almost always a mixed land use.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.