Skip to main content

Using EO Browser I’ve downloaded the NDVI index,
why the geotiff 32bit has 3bands and not a unique band with the NDVI value of the pixels ?
Is possibile to obtain a one band raster? Or which of the 3 bands is the correct one ?

many thanks

Hi,

You get 3 bands because NDVI layer in EO browser is a visualized layer therefore has RGB bands.

Yes it is possible to download only 1 band with actual NDVI values on EO browser.

Please refer to this thread for a detailed answer.

You need to first create your custom layer using this script below which returns 1 NDVI band

//VERSION=3
function setup() {
return{
input: [{
bands: ["B04", "B08"]
}],
output: {
id: "default",
bands:
}
}
}
function evaluatePixel(sample) {
let ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04)
return [ ndvi ]
}
  • instead of selecting NDVI, go to custom , then paste the script above to custom script section

 

  • When you go to download your custom layer, it should be 1 band, and you can also select geotiff 32 bit.

hope that helps, otherwise feel free to ask further questions




Thank you for your answer, but I get errors on the script.

I cannot find the error…

many thanks

Regards

Hi,

Sorry, there was a typo in the code: it is missing the parameter that sets the output number of bands, which in this case should be 1.

If you try the following Evalscript, it should work (see example):

//VERSION=3
function setup() {
return {
input: "B08", "B04"],
output: { bands: 1 }
};
}

function evaluatePixel(sample) {
var ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04);
return ndvi];
}

Note: this script in itself is designed for display purposes (scaled to the range 0-255). However, when you select Image format: TIFF (32-bit float) in the download section of EO Browser (under Analytical) the system will retrieve the raw values in Float for you.


 
//VERSION=3
function setup() {
return {
input: "B08", "B04"],
output: { bands: 1 }
};
}

function evaluatePixel(sample) {
var ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04);
return ndvi];
}

Hello,
thank you very much. Yes It works fine! great!

Best Regards
 


 
maxim.lamare:
//VERSION=3
function setup() {
return {
input: "B08", "B04"],
output: { bands: 1 }
};
}

function evaluatePixel(sample) {
var ndvi = (sample.B08 - sample.B04) / (sample.B08 + sample.B04);
return ndvi];
}

Perfect, this works, thanks very much


Thanks

much apreciated

works for normalised burn ratio and helped me understand how the code works 😀``


//this one is for landsat 4-5 but its always nir-swir/nir+swir eg sentinel2 would be B08-B12/B08-B12...
//VERSION=3
function setup() {
return {
input: t"B04", "B07"],
output: { bands: 1 }
};
}

function evaluatePixel(sample) {
var nbr = (sample.B04 - sample.B07) / (sample.B04 + sample.B07);
return rnbr];
}

//remember when you download the image to select geotiff and 32bit

Reply