Supervised and unsupervised classification, Sentinel 2

sorry, I actually meant the black outcome. I wondered if it maybe just isn’t displayed correctly. Maybe you can check, if there are values from 1-3 or if everythin is nan (not a number).

In the latter case: Right click on the result band ‘labeled classes’, select properties and see what is entered in the no data value.
Maybe the -1 is somehow messing it up.

Ok. I’ve checked the Pixel Info and everywhere is either NaN or Invalid pos. I played around with the no data value (changed to positive values and un-ticked the No-Data Value Used box) and nothing happens. I also changed the Confidence condition to see if that was affecting the result but that didn’t change anything either. Here’s the Labeled Classes properties default settings:

@ABraun could you please tell me how to these geometries?
I would like to select an area to became training area, and when I click that Icon, it opens a window called ‘New Vector Data Countainer’, I change the name and… what next?

I see that on the product explorer > vector data menu, this new vector is added, but I don’t know how to draw the shape I want.

Thank you in advance!

first you create a container with the right name. Then you select it by clicking on the corresponding class under Vector Data and use one of the digitizing tools: Rectangle, polygon or circle.

You can just digitize it by clicking in the image. You can then check if your geometry was placed in the right container:

Dear @ABraun thank you for the reply.
I managed to do it, but when I check the geometry it cames out blank on the polygon box:

Here is a screen shot of some of the polygons:

I wonder if after drawing them I should save the vectors somehow?..

I tried to do a KNN classifier, and I got this (I selected the option “Add Opened” in Prodcut-Reader window:

And besides not showing the vectors in training vector window, it also says "Error in Graph: [NodeId: KNN-Classifier] Source products are off different dimensions’’.

I wonder howcome, since the product where I drew the polygons, was built with math bands after resampling all the bands to the same resolution (I can even create composite with all of them). They all have the same resolution.

Any idea/tip on this @ABraun ?


yes, you have to select File > Save product first. Then your changes will be applied.

1 Like

I did it File > Save product and it stills showing blank on the style_css box…

Nevermind. This box stills empty, but the vector appear now… : ) THank you @ABraun

@andy: Did you find a solution to your problem?

No. It’s a bit disappointing that I cannot get it to work as I would like to use SNAP for my research. I’m now using QGIS to implement the Maximum Likelihood Classifier instead.

How can I visualized the supervised classification?

Best regards,

open the ‘labeled classes’ raster. In your case something went wrong. When no class distribution is calculated in the Frequency colum all raster cells are nodata (thus unclassified). I hat similar issues and didn’t find a solution for it so far. It changed when I selected different input data. But until now I couldn’t narrow it down to which one causes the faulty results.

Thanks for your reply.
Does the supervised classification work?
Best regards,

In general it works fine.
For some data there are errors. But give it a try - in most of the cases it will perform great.

Good morning everyone,

I am also a student trying to work with the Supervised Classification.
I am trying to classify a raster formed by several bands, each of them containing the temporal profile of a VI o similar features; the bands were derived from landsat8 data.

I have tried to perform the Random Forest and I got the error “bound must be positive”, even if all the values of the used bands were >=0.
I have also tried with MLC and MD, but, just like the people above in this discussion, I got a blank raster, full with NaN.

Has anyone managed to understand what is the problem behind these errors?


‘bound’ could refer to the coordinates of your data. Did you project your raster to a coordinate system? Which one?
What kind of data are you working on?

Generally in java this error means your item is empty, here your image (if a java expert can confirm ?) and when he tries to jump to the next item’s object (pixel) bound is negative (don’t know if it’s clear).

So there’s a problem with the image reading I guess (again if someone can confirm would be great :slight_smile: )

hi , Unfortunately I have the same problem

After the reprojection, I got some output:

Thanks for your reply.



I want to make a supervised classification (RF or SVM), I chose the region of interest, when I do the classification RF I receive the following error “bound must be positive”, I made the reprojection and still I have a problem: the LabeledClasses layer is displayed in black, I can not see the different classes.

Please help me solve this problem

I need tutorials, documents or video on classification under SNAP