Random Forest Classification with Sentinel 2

what I am saying this image does not even have clouds but yet it shows 100% deforestation. Can you be more detailed about my training datas. Also I don’t have sen2cor, what can I do?

of course it has. They are just not visible in B11 and B12. And I am quite sure that these clouds cause the faulty classification.


All the white spots are clouds. Your training areas should only contain pixels without clouds and your training rasters should contian B1 to B12.

sen2cor radiometrically calibrates your image to surface reflectance (L2A). It is advised if you want to compare images of multiple dates.
If available in the archive you can also download the calibrated products (L2A) instead of the uncalibrated (L1C).

Hi I am now trying the SVM method suggested in the manual of Deforestation monitoring with Sentinel-2. And now I do not understand how they got output model for classifying (marked in red) and the Output Confusion matrix (marked in blue). Please help me.
Please find the attached image here.
Regards,
Azmery![s2|690x387](upload://7nrjrWIhjm8vdCfGTojj3aYche5.jpeg)

Andreas
This discussion is very usefull, I learn from trial and errors
to adress my topic : above ground biomass with sent 1 sigma0 HV signal using sent2 L2A training classes LAI products calculated from B4,B5,B6, B7 ( LAI -say leaf area index -is closely related to AGB )

I would like to use RandomForest classifier :I still do not use polsarpro ,( but am going to )
-in winter wheat
-how many trees would be optimal ( 200 ?) knowing that my goal is to get as many as 4 classes in the resulting classification
-Reading this topic you gave me an idea : i shall not use vectors but pixels ranges training rasters ,each one specific to a class of LAI that fits to the patterns I see in the fields .
-Is a number of total pixels of about 700 sufficient ? ( 160 per classes ) resolution 10x10 meters
-is it possible to make a recursive boucle for - is it already implemented in R Forest ?
As you say , perhaps I shall not get a high accuracy , but some litterature show good results
I hope my questions are not too stupid !!
Many thanks

Best regards
Bruno

if you have the capacity to run 200 trees, you can do it. There is usually a saturation at which the quality no longer increases. But generally, the more trees, the bigger benefit is retrieved from the randomization. This also depends on the number of input layers. If you have only 2 bands, there is no way to randomize and recombine them in multiple way so the only random component is the subset of training pixels. Again, if you have digitized 700 pixels, setting this value to 2000 won’t bring any improvement. So the number of training samples should be smaller than the absolute sum you have because then a different subset is selected with each realization (each new tree) and by this, the algorithm sequentially finds rasters and thresholds with the highest impact.

I still recommend using vectors as training polygons, but if you manage to create rasterized training samples (with NoData at all non-training areas), it should work as well.

Generally, random forest works best with large training inputs (many bands and lots of samples), because only then the randomization is effective. Using only VH band is technically possible, but kind of ruins the whole idea of the RF algorithm. Or did I misunderstand your point and you are using a series of VH bands of different dates? This, in turn, would make sense very much, because the temporal variation is then part of the feature space.
I wonder why you use a classification method to model a gradual variable, such as the LAI. Wouldn’t be a regression, for example, more suitable?

I’d like to comment on this by bringing the comment of our colleague @johngan

Source of the post

Accordingly more features leads to lower accuracy!

He might be right in a way that texture rasters (GLCM) are highly redundant and often have only few differences. For each tree, a subset of all input rasters is used for training (often the square root of available). That means, it does have a positive effect if I have 3 training inputs or 12. But it will probably no longer increase the quality if I have 25 or 35.

If I have only one or two bands, each tree is based on the same data - therefore it is no longer decesive if I run 10 or 100 trees. Therefore, all the parameters play together - number of input rasters, number of samples and number of trees. Increasing only one while the others are low will not lead to better results.

1 Like

Is there anyone know how to get the Random Forest plugin in SNAP 6.0
I could not find it when installing SNAP.

Seemingly your SNAP missed many other classifier as well, please check up the update ,

Help-------》 check for update

1 Like

Thank you Falahakhri,
I did make an update, but the tools stay the same.

By the way, anyone know how to increase the RAM for improvement of running SNAP? It is set default for 4GB now (see the red circle).

In this case I think the best solution is, uninstall the SNAP, be sure to delete all the folders related to SNAP after uninstall it for instance, .SNAP .gdal, etcl.
Then redownload and install the latest version, concerning the RAM, I think 4, and 8 GB RAM are not enough, but 16 GB could work fine,

To increasing the memory, please take a look at the following post,

Source of the post

2 Likes

Thank you Falah for your recommendation. I re-installed the SNAP and got some addition classifiers.

The allocated Memory seemed automatically upgraded to 20025 MB (see the below image)

Best,
Giang

Hello,

I’m trying to classify my image with Random Forest but nothing hapens and I dont know why.




There is no data in frequency. So, it’s not computing.
What am I doing wrong?
Somebody can help me please?
Thanks,
Claudia

Uncheck the Evaluate classifier option ,

Training area should be identified under vector data, not under mask, and it should be reproject to WGS84 (unit=degrees), EPSG:4326 , similar project should be done to your S-2 image,

Take a look at this tutorial : CROP MAPPING WITH SENTINEL-2 JULY 2017, SPAIN

Source: https://rus-copernicus.eu/portal/wp-content/uploads/library/education/training/LAND01_CropMapping_Seville.pdf

1 Like

Thank you all. It worked now after to reproject the image. Thank you very much!!!
May I include index images in the RF classification? For example (B1, B2, …B12, NDVI, NVWI, etc)?
Regards,
Claudia

Thank you for the tutorial!
Claudia

Random Forest can handle inputs of different types and ranges, so this is possible.

Hello,
How can I acces SAR and Optical data fusion for land applications material?
Thanks.

Please take a look at the following post explained by our colleague @ABraun concerning data fusion

Source of the post