Random Forest Classification on Sentinel 2 Mosaic


i am currently running the Random Forest Classifier on a Sentinel 2 Mosaic, however, the RF classifier seems to have problems with the overlapping part of the two original S2 images… one can clearly see the S2 overlapping part in the classification result…

What could be the issue here?


did you mosaic the two inputs before the classification ord id you classify both individually and then mosaic the result?

I first mosaic the two inputs, then classified.

the RF classifier is quite sensitive to small variations because it is based on pixel thresholds.
Smaller inconsistencies between both tiles are possibly causing this effect.

Some ideas

  • use L2A products instead of L1C (if you are not already doing this)
  • create training polygons in both sides of the image to include these variations
  • test the KD Tree Classifier which could be a bit more robust towards this.
  • Increase the number of trees in the RF classifier (not sure if it solves the problem but also makes the classifier more effective)

thanks for the advice, i was not using L2A

i now used KDTree Classifier, however still the same result, even though i increased the amount of training polygons on both sides

This might be a silly question, but which bands are you using to perform the classification?

I see your point. Sentinel-2 has many additional bands which contain quality flags and geometric information. If they are used to train the classifier, you will inevitable introduce weird patterns.

1 Like

I used B2, B3 & B4

three bands do not make much sense to me, because the strength of the RF classifier is to shuffle the input bands repeatedly to make use of the most relevant ones. Why are you not using all 12 bands?

Please have a look at the discussions here: Number of training samples at Random forest classifier

I will repeat the process using all 12 bands and post the result. Thanks forn the advice, i lost the other bands during mosaicing the image.

Problem solved! Thank you!

So there is mo longer a pattern at the tile edge? Can you tell what made the difference in the end?

I used all bands for mosacing, and then der RF classifier worked just fine, so i think the problem in the first place was, as you said, only using 3 bands.

very good, thank you for reporting!