Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[best practices] Optimal parameters for rain forest region #94

Open
hmvege opened this issue Nov 5, 2021 · 4 comments
Open

[best practices] Optimal parameters for rain forest region #94

hmvege opened this issue Nov 5, 2021 · 4 comments

Comments

@hmvege
Copy link

hmvege commented Nov 5, 2021

Hello all,

I am curious to know if there exists a set of best practices when it comes to running MAJA on ROI covering a rain forest, where the number of cloudy days are > 350, what would be the best way forward?

Running with default settings did unfortunately produce a large amount of false negatives. In the example below I've extracted the cloud mask from the CLM_R1.tif-tile as any bit != 0. A section of the tile T49NEA is seen below:

cloud-mask

From reading #91 I understood that one should in general use more products for the backwards step when there are many cloudy images. There are also a whole host of settings exposed in the L2COMM GIPP file, which I wonder if may need some tweaking.

When running MAJA with following example settings,

$ startmaja -t T49NEA -f /src/maja/folder.txt -d 2019-03-01 -e 2019-09-30 --output_format natif --platform sentinel2 --nbackward 16

I encounter the following warning for (what it seems) every band of every input tile(lightly formatted with line breaks to fit line better):

2021-11-02 16:23:03 [93] WARNING MAJA 4.4 get_detfoo_index_shift:925 
Sentinel2L1ImageFileReaderBase::get_detfoo_index_shift: The detector indices are not in ascending order or do not have a constant shift with the feature indices in the MSK_DETFOO 
/src/maja/work/Start_maja_956da6b0be00592fb2dcf58eefd6d18b/S2A_MSIL1C_20190422T024551_N0207_R132_T49NEA_20190422T071959.SAFE/GRANULE/L1C_T49NEA_A020006_20190422T030127/../../GRANULE/L1C_T49NEA_A020006_20190422T030127/QI_DATA/MSK_DETFOO_B04.gml !

which from reading the aforementioned issue, the reason for this seems to be due to a large amount of clouds present in the imagery (but I may be wrong).

Note that I am running a containerized version of MAJA, built as suggested in issue 80 here and partly with the example seen here.

To verify that MAJA the install is correct and the settings for T49NEA work for other regions, I run MAJA on a region (T32VNM) and time where cloud free scenes exist and compared with sen2cor. Cloud masking on the left is in white, slightly opaque, for MAJA, and on the right, sen2cor cloud mask is seen with pixels blacked out(but clearly not covering all of the clouds).

maja-vs-sen2corr-32vnm

To summarize:

  • What settings are recommended for running MAJA on tile products of a rain forest, where the large majority of available images are partly of entirely clouded?
  • Is it recommended to provide a clear-sky-reference or similar, although that may not exist in all cases?
@olivierhagolle
Copy link
Contributor

Hi Mathias,
that's an interesting question, and it's true that with its nominal parameters, MAJA is not at its best over tropical forests. MAJA's strength originates from the use of multi-temporal information, using a previous cloud free observation as a reference.

Over sites where 95% of the pixels are cloudy, previous cloud free and not too old pixels become difficult to find. As the multi-temporal methods require more computing, we have to work at a coarser resolution to spare computing time. And over tropical forests, there are plenty of small clouds.

This is why using Fmask might be a better compromise for cloud detection on tropical forests. On our side, we did not work much on adjusting the parameters of MAJA on these places (but we definitely should), I don't have sure answers on how to tweak the parameters. But if you have time to try, it could be interesting.

First, the coarse resolution should be 120 instead of 240. It will detect part of the smaller clouds.

A description of the meaning of the cloud masks parameters is available here. It's a bit old and should be updated.

You could try to improve the multi-temporal detection to adapt it to the forest area, even if it will have drawbacks. Tropical forests tend to change less rapidly than agriculture fields. The current config is;

    <!-- Minimum Threshold on surface reflectance variation with time in the blue band -->
      <Min_Threshold_Var_Blue>0.016</Min_Threshold_Var_Blue>
      <!-- Maximum Threshold on surface reflectance variation with time in the blue band -->
      <Max_Threshold_Var_Blue>0.060</Max_Threshold_Var_Blue>
      <!-- Time delay after which Refl_Variation_Threshold is doubled (in days) -->
      <Cloud_Forgetting_Duration>45</Cloud_Forgetting_Duration>

You might try to decrease the first value, and increase the third. The threshold used in the multi-temporal detection increases with the time lag wrt the reference observation. It doubles every 45 days with the current parameters. This could improve the results in general, but classify as clouds some changes in reflectances.

You might also use stricter values for the cirrus band threshold (0.006 or 0.005), the current value being

<Cirrus_Mask_Threshold_Offset>0.007</Cirrus_Mask_Threshold_Offset>
      <!-- Gain for reflectance threshold to detect a cirrus -->

If you try those, I am interested by the impact you'll observe
Olivier

@hmvege
Copy link
Author

hmvege commented Nov 5, 2021

Hi Olivier,

thank you for such a quick reply.

I will tweak the parameters as suggested and report back the results.

Mathias

@hmvege
Copy link
Author

hmvege commented Dec 22, 2021

Hello again Olivier,

My apologies for taking this long for getting back to you.

We did do some experiments with MAJA for different settings, and it seems the lack of clear-sky days in the rain forest were consistently problematic.

The GIPP settings for MAJA, were (with everything else being default) and with grid settings set to 120m:

    <!-- Minimum Threshold on surface reflectance variation with time in the blue band -->
    <Min_Threshold_Var_Blue>0.010</Min_Threshold_Var_Blue>
    <!-- Maximum Threshold on surface reflectance variation with time in the blue band -->
    <Max_Threshold_Var_Blue>0.060</Max_Threshold_Var_Blue>
    <!-- Time delay after which Refl_Variation_Threshold is doubled (in days) -->
    <Cloud_Forgetting_Duration>55</Cloud_Forgetting_Duration>
...
    <Cirrus_Mask_Threshold_Offset>0.007</Cirrus_Mask_Threshold_Offset>
    <!-- Gain for reflectance threshold to detect a cirrus -->

We also tried for some other settings, e.g. lowering the Cirrus_Mask_Threshold_Offset, or increasing Cloud_Forgetting_Duration further, but that yielded similar or worse results. Reading at the description of some the parameters seen here, we also tried lowering Cloud_Blue_Reflectance_Threshold to 0.20, but that too did not improve the cloud detection.

Per your suggestion, we also tried using FMask, which gave fairly good results for the rain forest. Below is a comparison between MAJA, FMask, and S2Cloudless. The image seen is one of best clear-sky images seen in the rain forest for the target period.

cloud-detection-comparison_10mb

If you have any other settings that can be tweaked, I could try that, otherwise FMask yielded good enough results for our purpose.

Thanks again,
Mathias

@olivierhagolle
Copy link
Contributor

Thank you Mathias for the feedback and report of your tests to improve MAJA performances over rain forests. I guess the cloudyness is simply too high there for MAJA's multi-temporal methods to be efficient . As Fmask fits your needs, don't search more.
Best regards,
Olivier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants