Random Forest Classification

Hi, I am a new SNAP user trying to do a Random Forest Classification.
For that, I preprocessed the image I want to classify and I created a shapefile with the ROI in QGIS.
I am trying the train on vectors classification. For that, I have found the following problems or doubts:

  1. What do I need to put in -vector training , training vectors-? (which file and its format)
    I thought I should put my ROI shapefile or something like this, but, I cannot open any shapefile with the program. (please let me know how to open them)
    2- What do i need to put in -feature selection, feature bands-? (again file and format).

Thank you very much

you can import your vector as described here: Removing land by masking

It could be points, but polygons are better.

About the inputs, maybe this helps you: Rndom forest classification steps

Ok, Thank you :slight_smile:

After all, i ended up with this another error: javax.imageio.IIOException: 16-bit samples are not supported for Horizontal differencing Predictor what does it mean?

This error has been reported previously. A workaround is to decompress the file using a 3rd party application such as gdal.

1 Like

Hi, I have again one question:

To avoid the "javax.imageio.IIOException: 16-bit samples are not supported for Horizontal differencing Predictor " error I introduced all the individual bands I want to do the classification to (it is a total of 29 bands); then I imported my AOI (polygon shapefiles) while selecting one of those bands, then I finally was able to run the classification.

Everything seemed to work well except for the results; I ended up with 2 bands: LabeledClasses and Confidence. When I export this file into a tiff, I obtain a black image without data. The same happens in SNAP.

How can i do it better to interpret the results?

Thank you

@AnaV

Can you share somee screenshots to see your results?

If you want to export the classification, open it (LabeledClasses), go to File -> Export Image, select your output format and save it.

If you open this tiff in QGIS for example, you will have to change the style scheme that is used. Make sure you select “singleband pseudocolor”

@AnaV

Definetly, you RF did not work properly. Check that your preprocessing is okay and run again the classification. What are all the steps you are doing?

For the classification i am using 29 raster bands, belonging to 6 different rasters: NDVI, NDBI, NDWI percentil 50 and 90, sentinel 1 and sentinel 2 images and tasseled components images aswel.
The AOI are shapefile polygons created with QGIS and I am importing them into my first raster band

try working with orfeo QGIS or build your training rois directly on snap and export them to ESRI shapefile

Hi. I am currently performing a RF image classification. However, I always got the same result (See img below).

Result: 1 class with 100% frequency while the remaining classes were all 0, hence the image results to 1 color only.

May I ask what could be the possible reason for this? I have read some postings here in the forum and tried it but got same result. Thank you

have you tried if it is related to the coordinate reference system?


Besides that - can you please show your training data (in the map and also in the Vector part of the product)

Yes, I have tried reprojecting the data and import the shapefiles as my training data.

Are there any limits as to the number of training data (polygon)?

here’s my training data

Is that correct or that should be in m?

looks alright so far. There is no upper limit for training samples, so the produced map should show at least some class variation.
Which bands did you select as input features?

I did use Band 2,3,4,8,11,12,NDVI. I usually selected them all at once

I’ve been using SNAP to compare the results of Random Forest classifications of Landsat’s 8 and 9. Both images have different number of pixels, so I can’t band math them. How can I solve it?
Also, is there a way to turn these LabeledClasses images to a shapefile or vector data?