Hello,
The reason you got 3 bands when you downloaded the NDVI product from Sentinel Hub EO Browser is that the script is designed for visualisation purposes only. Indeed NDVI values are mapped to RGB values, so when you download the product, you get the 3 RGB bands.
To retrieve the NDVI values you need to use the Custom Script functionality of EO Browser. You can also use our Requests Builder tool, recently announced in the Forum. Thanks to its graphical interface, the tool makes querying data really easy, as most of the code is written for you!
Back to NDVI, you can either request the data as floats or as integers and convert them back to float values on your side (in QGIS for example). Since the latter requires less Processing Units and smaller files, I’ll post an example with integers.
Once you have set your date and location of interest for Sentinel-2, you can use the following evalscript either in EO Browser or in Requests Builder :
//VERSION=3
function setup() {
return {
input: ["B04", "B08"],
output: { bands: 1, sampleType: "UINT16" }
};
}
function evaluatePixel(sample) {
let ndvi = index(sample.B08, sample.B04);
return [10000 * ndvi + 10000];
}
The setup
function specifies which bands you want to use and the output expected. Here we want 1 band as unsigned 16-bit integers.
In the evaluatePixel
function, the ndvi
is first computed. In the return statement, we then multiply the NDVI values by 10000 and add 10000. This way NDVI spans [0, 20000], and you can rescale back down to [-1,1] by doing:
ndvi_float = (ndvi - 10000.)/10000.
in QGIS or any other software.
Let me know if you run into any difficulties!
Maxim