Rndom forest classification steps

the NullPointerException is not telling us much about the source of the error, but we can try to narrow it down.

  • have you saved the product after importing the vector geometries
  • could the vectors contain invalid geometries?
  • are all used bands converted to a physical product?
  • are ther nodata values inside the texture layers? Please remove all “valid pixel expressions” and “no data” definitions in the properties of all bands and save the product.
  • have you tried running it with only the Sigma0 bands to check if the problem persists? This would indicate that the other bands cause problems

Dear @ABraun
messages.log (149.5 KB)
I try to reproject, and it could not be done with the below message.

  • I did save the product
  • I remove the vector file, and reproject, then the below message appear
  • All texture bands were in digital number (both negative and positive number) when converted to *.geotiff for stacking in SNAP
  • How do we check the “valid pixel expressions” and “no data” to remove them?
  • The sigma naught bands were OK.
  • The upload text file is the log file when I check for detail why the software does not work.

image

I check the data layer properties and remove all the check mark in row No Data value Used, then save it and run the classification again. It still does not work with the red words at the bottom of the dialog “Incomplete expression” :frowning:

please completely remove all the geometries from the product, save it and import them again.

If the RF works with the Sigma0 bands, there is something wrong with the texture layers. Please check the valid pixel expressions again if you have left a character or something (Missing ‘)’ sounds like there is an incomplete statement)

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.
Thanks

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.

image

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

Hi!
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

Cheers!

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.