jbferet / biodivMapR

biodivMapR: an R package for α- and β-diversity mapping using remotely-sensed images
https://jbferet.github.io/biodivMapR/index.html
GNU General Public License v3.0
47 stars 13 forks source link

+/- inf values in OutputPCA_8_PCs raster #21

Closed nklaudy closed 1 year ago

nklaudy commented 1 year ago

Hello,

I am having an issue where the output raster of the PCA (file named OutputPCA_8_PCs) contains many +/- inf values in each band. I am using the package sen2r to download Sentinel-2 data, which is in ENVI format. What may cause the PCA to produce such values and how can I solve it? I can supply more precise information if it is helpful.

Thank you very much in advance!

Best, Nikolas

jbferet commented 1 year ago

Dear Nikolas, I would need more information to provide an answer and solve the problem.

thank you, Jean-Baptiste

nklaudy commented 1 year ago

Dear Jean-Baptiste,

Thank you for your answer and sorry for the late reply! I have now set continuum removal to "False" which has resulted in normal-looking values in the PCA rasters and gives me spectral species maps and alpha/ beta diversity maps that also contain realistic values.

Thank you again for your help!

Best, Nikolas

jbferet commented 1 year ago

OK great! You may need to check your data in order to identify more precisely the reason for such infinite values. They may evidence improper data correction, or may be cause by very little amount of pixels which could be masked with no effect on final products, and would allow you to apply continuum removal (which proved to be very important to strengthen the relationship between spectral diversity and taxonomic diversity). --> I suggest that you produce a mask discarding all pixels with B2 or B12 reaching 0 value. Then you can judge if the amount of pixels discarded from your image is acceptable or not. If acceptable, combine this mask with the cloud mask and give it another try with continuum removal.

nklaudy commented 1 year ago

Hello Jean-Baptiste,

I checked and in my raster B6, B7 and B9 contain pixels reaching 0 value. Does it make sense to create a mask for these bands as well?

Again thank you very much for your help!

jbferet commented 1 year ago

0 value for B6, B7 and B9 should not lead to infinite values after continuum removal, unless the full spectrum shows 0 or negative values.

if you are working with vegetation, it seems pretty unlikely that B6 and B7 have reflectance value of 0, unless completely shaded. So yes, I would recommend masking these pixels as the signal will not provide any relevant information.

I am usually not using B9 as it is used for atmospheric corrections, and 60 m resolution which leads to questions regarding interpolation. Some colleagues do use B9, so I may be overly cautious.

Are you working with Sentinel-2 L2A images? I strongly recommend using L2A, not L1C. It may be easier to switch to emails to further discuss your case. my email is on my gitlab personal webpage. you can contact me directly for further assistance

nklaudy commented 1 year ago

Perfect thank you, I will mask the pixels and if I still have any questions/ issues I would contact you directly.