I used the otbcli_RadiometricIndices function, inputting a hypercube that I created with the different Sentinel-2 images corresponding to each band. I’m looking to make a mask for the water so I used -list Water:NDWI (I also tested with NDWI2).
Unfortunately, the image created at the output is all black. I don’t understand how this function works and what the values to put in the different channels (R, V, B, NIR and MIR) correspond to.
Could you help me understand how this function works and how I can successfully make a mask using radiometric indices of interest?
the channel parameter should be used to specify which band corresponds to which spectral channel. In the case of a 12 band Sentinel 2 cube, where the first band correspond to B01, the second to B02 etc, you should set it as :
channels.blue : 2
channels.green : 3
channels.red : 4
channels.nir : 8 (near infrared)
channels.mir : 11 or 12 (medium infrared)
Note that you only need to set the channels that will actually be used to compute the requested indices. Here NDWI is (nir-mir)/(nir+mir) and NDWI2 is (green-nir)/(green+nir). According to wikipedia, NDWI2 is more suitable to build a water mask (NDWI can be used to monitor water content in vegetation).
I created my hypercube with only my bands 2, 3, 4, 5, 6, 7, 8, 8A, 11 and 12. So my image has 10 bands where band 2 is the first. Does this mean I have to put “channels.blue 1”… etc. ? Since band 1 of my hypercube corresponds to my band 2 of the Sentinel data.
I also looked at how to apply a threshold with BandMath but I can’t find a way to do it. Do you think about the same method as in the link “Images with no-data value” that uses ManageNoData ? Or do we have to use an expression or something else ?
BandMath is the “calculator” application of OTB, and it can be used to perform many pixelwise operation on input image. To perform thresholding, you need to use it as follow:
il is the input image list, here you only have one image.
out is the output image
exp is the expression to be applied on each pixel. im1b1 means first image and first band, and the logical expression im1b1>0.5 is evaluated on each pixel (I’m not sure about the 0.5 value, it depends on the NDWI value.
This will create a binary mask image, where 1 corresponds to water and 0 to land.
The ManageNoData application can be used to manipulate the no data flag of the image. For example you can use it on the input image along with the created mask to modify all water pixel to the no data value. Depending on what you want to do, you might want to use this application, but be aware that many applications in OTB won’t take the no data flags into account.
According to this source, water bodies have NDWI>0.5, while vegetation usually have negative values. Built up areas have values between 0 and 0.2.
So maybe something like 0.3 is a good value ?
Also according to this paper, if your image has a lot of built up areas, you might want to use MNDWI (also available in OTB!), it uses the green and MIR channels (B03 and B11 if I’m correct).
Thank you, I found the same source and indeed 0.3 is a good value to get my water mask with the NDWI2.
I am now looking for a good threshold for the NDBI which tends to take bare ground in addition to urban. I have tested several values between 0 and 0.2 but I don’t think I could have anything perfect. I’m thinking of testing the Index Surfaces Built to see if I can get something better.
I found this for the ISU index (here) : ISU = A + B * (R/NIR).
For SPOT, A and B are apparently constants worth 100 and 25 respectively but it is impossible to find their value with Sentinel 2. Do you know anything about this index? because I can’t find anything on the internet.