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

**URL:** <https://forum.orfeo-toolbox.org/t/spectral-angle-classification-input-validity-mask-handling-nodata-values-in-image/997>\
**Category:** OTB Usage\
**Created:** [March 31, 2021, 4:17pm UTC](https://forum.orfeo-toolbox.org/t/spectral-angle-classification-input-validity-mask-handling-nodata-values-in-image/997 "2021-03-31T16:17:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rdzur](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/rdzur/32/386_2.png) [@rdzur](https://forum.orfeo-toolbox.org/u/rdzur)\
**Post date:** [March 31, 2021, 4:17pm UTC](https://forum.orfeo-toolbox.org/t/spectral-angle-classification-input-validity-mask-handling-nodata-values-in-image/997/1 "2021-03-31T16:17:35Z")

</div>

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.

## Rob

---

<div class="post-metadata">

**Author:** ![Cedric](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Cedric](https://forum.orfeo-toolbox.org/u/Cedric)\
**Post date:** [April 2, 2021, 8:51am UTC](https://forum.orfeo-toolbox.org/t/spectral-angle-classification-input-validity-mask-handling-nodata-values-in-image/997/2 "2021-04-02T08:51:07Z")

</div>

Hello,

Maybe you can use the different modes of the [ManageNoData](https://www.orfeo-toolbox.org/CookBook-develop/Applications/app_ManageNoData.html) application to build a mask from the input image and apply it to the classified image

```auto
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

```

Cédric

---

<div class="post-metadata">

**Author:** ![rdzur](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/rdzur/32/386_2.png) [@rdzur](https://forum.orfeo-toolbox.org/u/rdzur)\
**Post date:** [April 2, 2021, 12:43pm UTC](https://forum.orfeo-toolbox.org/t/spectral-angle-classification-input-validity-mask-handling-nodata-values-in-image/997/3 "2021-04-02T12:43:34Z")

</div>

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.

## Rob

---

<div class="post-metadata">

**Author:** ![Cedric](https://forum.orfeo-toolbox.org/letter_avatar_proxy/v4/letter/c/ecd19e/32.png) [@Cedric](https://forum.orfeo-toolbox.org/u/Cedric)\
**Post date:** [April 2, 2021, 12:50pm UTC](https://forum.orfeo-toolbox.org/t/spectral-angle-classification-input-validity-mask-handling-nodata-values-in-image/997/4 "2021-04-02T12:50:02Z")

</div>

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.

Cédric

---

<div class="post-metadata">

**Author:** ![rdzur](https://forum.orfeo-toolbox.org/user_avatar/forum.orfeo-toolbox.org/rdzur/32/386_2.png) [@rdzur](https://forum.orfeo-toolbox.org/u/rdzur)\
**Post date:** [April 2, 2021, 12:54pm UTC](https://forum.orfeo-toolbox.org/t/spectral-angle-classification-input-validity-mask-handling-nodata-values-in-image/997/5 "2021-04-02T12:54:03Z")

</div>

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.

## Rob
