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:
- QGIS has an option to set “no data value”. Try setting this to 0 and the image downloaded from EO Browser shall appear transparent outside of your aoi. This is because SH fills no data pixels with 0 by default. You can overwrite this and use custom value as described here: https://docs.sentinel-hub.com/api/latest/user-guides/datamask/#example-1-assign-an-arbitrary-value-99-to-no-data-pixels .
- If you are downloading images as .png from SH, then transparency of pixels outside of aoi can be achieved by returning dataMask as 4th band (this is what my script above does).
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.