Rndom forest classification steps

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.

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

Sure!

also, geographic coordinates, as required. Can’t find an error here. Did you digitize them yourself or did you import the polygons from shapefiles?

I digitized them myself…
I could use other satellite data like L8, but this time I’ll participate in a Copernicus Workshop (for Latam users comunity) and I want to show the capabilities of SNAP software and S-1/S-2 data. If you have some other ideas later please let me know!

maybe a dumb suggestion, but have you tried re-creating this workflow from scratch? Sometimes, little errors sneak in unnoticed.

Will do! Let you know if it works, many thanks for your time :slight_smile:

Dear ABraun,

I tried again and worked, can’t tell what happened :roll_eyes:

Thanks again!

I’m still facing some issues with that S2 image.
When I run the RF class. the borders with NaN values are classified under the 0 value class:


As I read before, I checked the properties of every band in the image, clicked on No-Data Value Used and wrote NaN for it.
imagen
I ran the process many times and restarted SNAP just in case, but I always have NaN pixels mixed and classified…
Moreover, when I use that S2 image combined with SAR bands, the same classification looks fine:

Any idea what could it be?

would it help to make a mask of the no-data areas before classification and then simply apply it as valid pixel expression afterwards?

Perfect! Many thanks for the idea ABraun, just in case any other person needs to do this:
I created the complement of the original ROI mask and then entered this expression in the classified band Properties > Valid pixel expression: if LabeledClasses==mask then Nan else LabeledClasses.
:ok_hand:

1 Like

I have reached a point of total desperation: Trying to do a simple supervised Max Likelihood classification

S2B_MSIL2A_20210729T154819_N0301_R054_T18SUE_20210729T200736 - Copy
SNAP 8

Steps
Re-project to WGS84 (Save)
Resample to Band 2 (Save)
Subset (Save)
Create Vector Containers for each class on subset image
-Select all classes
-select all bands

Fail fail fail empty gray space every time but classes show up in color panel. Even after having success once it cannot replicate again. Why on earth wouldn Snap just be designed to use the given projection as the images it creates

Run classification

Why is your product called “waterMasked”? Maybe the error can be explained by what you have done in this step.

Can you please try to resample first and then reproject to WGS84?

I have tried with and without selecting a water mask in the mask manager: It never works either way. I want to mask out water before classifying as it gets muddled otherwise. If there is another way to mask after that would be great.

What would be really helpful is exact directions of what to do before attempting classification. I’ve spent three days trying to figure this out and have taken two full courses in remote sensing. I just don’t get why snap is so weird about classifying

Resample settings:


reprojected:

Then Subset to my area of interest
Then create polys
then run max liklihood

always nothing

I figured it out:

Open Original (unzipped) Sentinel 2 image >

Raster > > Geometric > Resample > CHECK SAVE and set folder to save to > Under Paramters: Select Band 2 for 10m resolution across bands (Save completed product)

Raster > > Geometric > Re-project >Re-project Parameters set to WGS1984

When you Subset, un-select all bands > then CHECKMARK bands 1-12

Then the classifications work