Classification: How to use saved classifier on another product


Hi all!

I am trying out the supervised classification with maximum likelihood.

Everything goes well from creating the geometry, then train and save a classifer.

However, how do I use this saved classifier on another product?

I loaded a product that I want to apply the classifier to, then it said this:

I created the same vector container on the product, and tried again, but the same error message is there.

Anyone knows how to solve this problem?


Supervised and unsupervised classification, Sentinel 2
Supervised and unsupervised classification, Sentinel 2

did you check “load and apply classifier” instead of “train and apply classifier”? This should actually read the ruleset created by the classifier trained in your previous product so no further raining vectors are needed.

Classification In snap

sorry i realised that I copied the wrong image…

i checked the ‘load and apply classifier’ but the same error remains…



ah, I see, sorry.

I tried it myself by splitting a S2 image into two parts. I collected training areas for four classes, only for the left one:

I trained and classified the left one:


Then I tried to apply the classifier to the second image:
I received the same error:


This sounds like a bug.
I’ve created an issue (SNAP-748) for it.

P.S. I’ve turned this into a separate thread.


Hi both!

Thank you for the responses. I look forward to having it worked out.



Hello all,

I tried to use the classifier again on another image… but this time is doesn’t work.

why is there the error of nullpointexception? i did not get this error message previously.

Anyidea how to solve this?

regards, Jessica


Hard to say without more information.
Can you post the massages.log file, please?
You find it when you click on Help / Show Log Directory in the menu, but first reproduce the error.


Hello Marpet,

messages.log (1014.3 KB)


I see a lot of messages which say that a file can not be found.
Have you moved the *.dim file without moving the corresponding *.data directory?


well… i restarted SNAP, deleted all the previous files and started all over again. same error.

here is the log message.

messages.log (66.2 KB)


This time there is no error visible at all in the log file.
Maybe @lveci knows something about it?


Hi Plz anyone have idea an how to classify Maximum Like…, i tried tis class… but i got tis error ,


Any update on the problem? I tried it again today but the same issue comes up.

messages.log (65.4 KB)

is it the problem with it being a jpeg file?




Same issue when classifying LANDSAT images. After several trials though I found out that all classifications work when the image is reprojected to WGS84 geodetic reference system (lat,lon). So it must be an issue due to wrong handling of the reference system

Running SNAP 5.0.7 (fully updated) on linux

Another minor issue on linux is that the maximum likelihood classifier searches for a file MaximumlikelihoodClassifierGraph.xml in /.snap/raphs/internal/classification/, but the existing file is MaximumLikelihoodClassifierGraph.xml (L uppercase instead of l lowercase)

Supervised and unsupervised classification, Sentinel 2

The upper-/lowercase problem is already fixed since January. Should have been in the 5.0.2 update.
At least it will be, with the next release.

@junlu can you have a look at the classifier?


Hi All,

I am encountering similar problems using Random Forest Classification. I tried what pol.kolokoussis recommended and reprojected to WGS84 but the same error occurs.

First, I tried loading the classified using “default” setup and this is what it looks like:

I thought I can try selecting ‘Train on Raster’ just to make error go away but still load my classifier which would end up looking like this:

But doing so and trying to proceed would just actually lead to doing another training on raster instead of applying the classifier.

Is there a possible work around for this?

Thanks in advance!


what do you mean by “Train on raster”?


Hi ABraun,

This is the same second image from previous response with the “Train on Raster” highlighted. I tried clicking it to make the vector error go away and then proceed to selecting my classifier thinking it would solve the problem. But even though there are no error notifications anymore, applying the classifier still does not appear to work and running it would just end up doing another training instead.

Hope this makes things clearer.


now I see, sorry.
Haven’t tested this so far.