Rndom forest classification steps

These are Floating point and Unsigned 8 bit data.
Do you mean some pixels were not Digital Number value?

the classifier wants to extract all pixel values under the training geometries. If one of them is defined as NaN (not a number) defined in the band properties. These are displayed transparent in SNAP.
Please also see here: Polarimetric Classification NaN problem

Thanks @ABraun for your sharing.
So was I right so set up as below? Or should I change NaN = 0

Please try -9999 for no data in all bands and save the product

Dear @ABraun,
I carefully check the input data;
Remove all the “Valid Pixel Expression”;
Un-check the No-Data Value Used
Set the Nodata as 0;
Save the product;
Then run the RF.

The message now as below: Java.lang.NullPointerException
It is really strange ;(

Dear @ABraun and @marpet
I tried with your suggestion to set the NoData (both for 0 or -9999)
Both option did not work.
The error is “Java.lang.NullPointerException” when run the Random Forest

Do you think the Unit as in the metadata is an issue? I can not make it run.

I don’t think the unit is a problem. But I noticed that you increased the number of training samples to 10000. If the training polygons are not large enough, this can become a problem.

Can you please try to run with 2000 samples and 10 trees - just for a test?

After you have run the process could you please post the log file. Probably there are more details visible, especially where the exceptoion occurs.
To get the file go to the menu and select Help / Show Log Directory.
Then select the messages.log file and attache to your next post.

Dear @Marpet,
Here is the log file I uploaded some days ago.

Kind regards,
messages.log (149.5 KB)

Thanks for the log file.
In the file I do not see the NullPointerexception you have reported before.
There is only an exception regarding the ProductSet-Reader and that a source product should be added. So file doesn’t help further, unfortunately.
Are you sure you picked the right log file?

@lveci Maybe you know what’s going wrong?

WARNING [org.esa.snap]: Graph parameter includeMaster not found for Operator CreateStack
org.esa.snap.core.gpf.graph.GraphException: [NodeId: 1-ProductSet-Reader] Please add a source product
	at org.esa.snap.core.gpf.graph.NodeContext.initTargetProduct(NodeContext.java:79)
	at org.esa.snap.core.gpf.graph.GraphContext.initNodeContext(GraphContext.java:195)
	at org.esa.snap.core.gpf.graph.GraphContext.initNodeContext(GraphContext.java:178)
INFO [null]: Last record repeated again.
	at org.esa.snap.core.gpf.graph.GraphContext.initOutput(GraphContext.java:162)
	at org.esa.snap.core.gpf.graph.GraphContext.<init>(GraphContext.java:91)
	at org.esa.snap.core.gpf.graph.GraphContext.<init>(GraphContext.java:64)
	at org.esa.snap.graphbuilder.rcp.dialogs.support.GraphExecuter.recreateGraphContext(GraphExecuter.java:272)
	at org.esa.snap.graphbuilder.rcp.dialogs.support.GraphExecuter.initGraph(GraphExecuter.java:252)

Sorry @marpet, There were several fails. That log file was appeared with the below message.


There is one message which says that you tried to open an RGB image and one of the expression wasn’t correct.
The “Missing ‘)’” might be related. I don’t know, maybe you changed some valid-pixel expression of a band or it is done by the operator and it goes wrong.
I’m also not very familiar with this operator.

Dear colleague,
Today, I tried again with my dataset and it worked. The approach as below:

  • Derivation of GLCM bands and Topographic indices bands. Check each band value. If the “Zero” value is exist, it is needed to be replaced by a proper number. Otherwise, these zero value will cause error in your stack image as well as the classification afterwards.
  • “Clean” all the input image/bands before stacking as @ABraun suggested (check the properties of each band and clear the Valid-Pixel Expression). I tried and found that it was OK with the option of checking No-Data Value Used (it means we accept the NaN).
  • Stack layers
  • Subset the raster dataset to focus on the study area
  • Check the band properties of the stack image again to make sure there is no surplus information (tick on No-Data Value Used to remove the NaN area), and Save the data file before using.
  • Run the RF classification.
    There was one time the error message appear like not enough memory. I restarted the SNAP, and it worked again.

Hope it helps,

1 Like

good to hear that you found a solution by a clean re-proessing of all steps! Thank you for sharing.

1 Like

I’m trying to combine S-2 and S-1 data for classification, but cannot get S-2 classified although I’ve reprojected it to Geographic lat/lon.
Does that happen to all S-2 data? (It’s a pity because I’ve found S-1 and S-2 images from the same date) Do I have to do sth else before?. These are my steps:

  1. Reprojection
  2. Resampling
  3. Land/sea mask with shapefile
  4. Definition of polygons
  5. RF classification


Currently, this affects all S2 data as long they are in UTM coordinates. After reprojection the error (out of bounds exception) should no longer occur.

The problem is that it still happens although it’s reprojected. I get a blank image after classification.
Could it be sth else?

what is displayed in the product geocoding? grafik

(I’m sorry I don’t know how to copy it in text format)

looks alright.
Can you please also show the WKT definitions of your training polygons (the content of Vector Data, maybe open one geometry as table).