otbcli_ManageNoData multiband image buildmask

Hi,

I try to build the nodata mask from a multiband image.
It outputs a single band image with the value 241.
Is it expected?
Is there a way to produce a mask with as many band as the input image?

OTB-9.1.0-Linux/bin/otbcli_ManageNoData -in S2_Hornsund_SC.tif -out tmpND0.tif -mode buildmask -mode.buildmask.inv 0 -mode.buildmask.outv -9999 -usenan 1

Thanks, best.

César Deschamps-Berger

Hi,
The output value can be explained because your output image have the same type as input image, here it seems to be detected as uint8.
When you transform -9999 in binary you get “1101 1000 1111 0001”. Transformed to uint8 you get “1111 0001” which is 241 in base 10.
To avoid this you can specify the output format (see the dtype in -out param in ManageNoData — Orfeo ToolBox 9.1.0 documentation ):

OTB-9.1.0-Linux/bin/otbcli_ManageNoData -in S2_Hornsund_SC.tif -out tmpND0.tif int32 -mode buildmask -mode.buildmask.inv 0 -mode.buildmask.outv -9999 -usenan 1

With this you get a single band image with 0 for NoData and -9999 for everything else.

If you want a nodata for each band, you can use the Extended filename otb capabilities. Thus your command will looks like:

OTB-9.1.0-Linux/bin/otbcli_ManageNoData -in S2_Hornsund_SC.tif?&band=1 -out tmpND_band1.tif int32 -mode buildmask -mode.buildmask.inv 0 -mode.buildmask.outv -9999 -usenan 1

Great, thanks.

You’re welcome! Note that with this method you will get one no data mask per band, does it solve your problem ?

Yes, thanks!