Spectral Angle Classification - Input Validity Mask handling nodata values in image?

Hello list,

I have been running some tests with otbcli_SpectralAngleClassification on MacOS v. 7.2.0. Testing thus far seems to yield reasonable results on a small test ROI image. This small test image does not contain any nodata values. As I have scaled up the test of otbcli_SpectralAngleClassification to a much larger image (which does contain nodata values), I have noticed that the nodata values appear to be included in the first endmember class rather than being retained as the background value (-bv 0). So, I guess I am curious how nodata values are being handled in the otbcli_SpectralAngleClassification. I also did not see the availability of a parameter for a validity mask or image validity mask in this application. Am I missing that flag to handle the nodata values in the image or is there another way to deal with nodata values within otbcli_SpectralAngleClassification that someone would be able to advise on?

As always thank you for your kind assistance.



Maybe you can use the different modes of the ManageNoData application to build a mask from the input image and apply it to the classified image

otbcli_ManageNoData  -mode buildmask -in input.tif -out mask.tif
otbcli_SpectralAngleClassification -in input.tif -out classified.tif ...
otbcli_ManageNoData  -mode apply -in classified.tif -out classified_with_nodata.tif -mode.apply.mask mask.tif


Hi Cedric,

Yes in fact the ManageNoData option you suggest is quite effective at restoring the nodata values back to the classified image. Thank you. Do you happen to know if the results may be affected by the presence of nodata pixels during the otbcli_SpectralAngleClassification process?

Thank you again.


Hi Rob,

the classification of valid pixels should not be affected by the no data pixels because each pixel is processed independently in the SpectralAngleClassification application.


Great Cedric,

Thank you for that information–that is good to know. I very much appreciate your assistance to help me understand this particular aspect of the Spectral Angle Classification result.