Skip to main content



How can I delete the black part of the image so I can get just the NDVI in my AOI?

Hi,

you need adjust custom script of your layer to use dataMask band as explained here: https://docs.sentinel-hub.com/api/latest/user-guides/transparency/#transparent-no-data-pixels

An example of a custom script for visualization of NDVI which will make pixels outside of your AOI transparent:

//VERSION=3
//NDVI

function setup() {
return {
input: [{
bands: [
"B3",
"B4",
"dataMask"
]
}],
output: {
bands: 4
}
}
}

function evaluatePixel(samples) {

let ndvi = (samples.B4-samples.B3)/(samples.B4+samples.B3);
return colorBlend(ndvi,
[0.0, 0.5, 1.0],
[
[1,0,0, samples.dataMask],
[1,1,0, samples.dataMask],
[0.1,0.31,0, samples.dataMask],
])
}

Thanks! But it still doesn´t work. I tried your code and another specifically for Planet data that was int the “docs” link you mentioned but I couldn´t download a “clipped” image. I also tried to upload my AOI again to see if this would help the “clipping” process but didn´t work either. Finally, I tried several kinds of “Downloads” in Analytical but none resulted. Any other advice?


Hi,

I double checked the evalscript I posted above and pixels outside of your aoi are transparent:

However, it seems that you struggle with the downloaded image not with the wms layer. What exactly do you mean by “download a “clipped” image”? An image always has a rectangular shape. I assume you would like pixels outside of your aoi to be transparent in the software which you use to open the downloaded image.

There are different things you can do to achieve this depending on the software and your download format:

If this doesn’t help, could you explain the steps you do a bit more into details: how you download the image from SH, in which software do you open it then and what do you see.


Thanks again! I downloaded the TIFF images from EO Browser and I assumed that I would be clipped to the polygon. I use QGIS and NextGis. Maybe it is better to use the SH pluggin that shows the way you show the image and add my base map there. Thanks!!


Reply